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,
                          'sn' => $lastname,
                          'physicaldeliveryofficename' => $row[8],
                          'telephonenumber' => $row[9],
                          'mail' => $row[13],
                          'streetaddress' => $row[2],
                          'l' => $row[3],
                          'st' => $row[4],
                          'postalcode' => $row[5],
                          'title' => $row[6],
                          'department' => $row[7],
                          'pager' => $row[12],
                          'mobile' => $row[11],
                          'facsimiletelephonenumber' => $row[10],
                          'objectclass' => ['top', 'person',
'organizationalPerson', 'user'],
                          ]);

This is the error I get. I believe the double single quote is giving
me problem.

Total entries returned: 3
failed to add entry: 0000202B: RefErr: DSID-031006D9, data 0, 1 access points
        ref 1: 'cnb.lab''


I tried to fix it by making the following changes 

    $dn="dn => cn=$cn, ou=retail, ou=users, ou=level2, dc=test, dc=lab";

and I end up with this error

0000208F: NameErr: DSID-03190843, problem 2006 <BAD_NAME> data 8349,
best match of:
  'dn => cn=Jane Doe, ou=retail, ou=users, ou=level2, dc=test, dc=lab'

Reply via email to