in reply to working with DBI and Net::Ldap::Ldif

line 96 is

$ldif->write($pwarray->[$i][0]);//string
which is the first line attempting to write to the LDIF file. You appear to be trying to write a string attribute value 'username'. Net::LDAP::LDIF expects the parameter to 'write' to be a valid Net::LDAP::Entry object. You need to construct a Net::LDAP::Entry object for every LDAP object you want to create in your LDIF file, and pass that to 'write'.

Example:

use strict; use warnings; use Net::LDAP::LDIF; use Net::LDAP; my @entryvalues = qw( testuser testcn testsn ); my $entry = Net::LDAP::Entry->new(); $entry->dn("cn=".$entryvalues[1].",ou=test,dc=test,dc=com"); $entry->add( "uid" => $entryvalues[0], "cn" => $entryvalues[1], "sn" => $entry[2], "objectclass"=> "inetorgperson" ); my $ldif = Net::LDAP::LDIF->new("file.ldif","w"); $ldif->write($entry);

--------------------------------------------------------------

"If there is such a phenomenon as absolute evil, it consists in treating another human being as a thing."
John Brunner, "The Shockwave Rider".

Can you spare 2 minutes to help with my research? If so, please click here

Replies are listed 'Best First'.
Re^2: working with DBI and Net::Ldap::Ldif
by philosophia (Sexton) on Feb 17, 2006 at 15:44 UTC
    thanks, that helped a lot.