I've been quite happy with using perl to prep csv or ldif files (ldif by preference) that I then load into AD using either csvde or ldifde with a system command. Also wondering that you're creating AD user entries without specifying their current state (userAccountControl) or login name (samAccountName) or initial password.
But anyway - to the root of the problem: you shouldn't need to single quote your dn - a regular string will work just fine. but don't but a dn pointer in the string. dn=> isn't part of the dn itself and you don't need one anyway.
From the Net::LDAP docs:
$result = $ldap->add( 'cn=Barbara Jensen, o=University of Michigan, c=US',
attr => [
'cn' => ['Barbara Jensen', 'Barbs Jensen'],
Note how the DN is just a DN with no pointer - it's the first element and required to be a plain old DN. Therefore:
$dn="cn=$cn, ou=retail, ou=users, ou=level2, dc=test, dc=lab";
my $results = $ldap->add($dn, ...should work just fine.
Cheers,
Erik
Le 18 mai 2005 � 01:22, wy a �crit :
Hi, I just joined the mailing list and is new to Net::LDAP. I was able to perform the necessary functions to Active Directory through Net::LDAP until I need to write a script to add a list of users to AD.
Here is a little snippet of the code:
while ( @row = $sth->fetchrow_array ) {
$firstname=ucfirst(lc($row[0])); $lastname=ucfirst(lc($row[1]));
$cn=$firstname . " " . $lastname;
$dn="dn => \'cn=$cn, ou=retail, ou=users, ou=level2, dc=test, dc=lab\'";
my $results = $ldap->add($dn, attr=>['cn' => $cn, 'givenname' => $firstname,
smime.p7s
Description: S/MIME cryptographic signature
