[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Net::LDAP

On Mon, 1 Nov 1999 mikema@crt.com wrote:

> 	Has anyone been successful using the Net::LDAP module in perl.  It
> seems to fail anytime I try and add.  I can search with no problem.  

Are you sure you're binding with the right privs? Check the result code and
error string. Check your slapd logfile if that doesn't help.

This ought to add entries from an LDIF file.

  $ldap = new Net::LDAP ("ldap.crt.com",);
  $ldap->bind(      dn => 'cn=root,dc=crt,dc=com',
              password => 'secret');
  open LDIF, "foo.ldif";
  $ldif = new Net::LDAP::LDIF (\*LDIF,"r");
  while ($myobject = $ldif->read()) {
    $myref = \$myobject;
    $result = $ldap->add($myref); 
    $result->code && warn "failed to add entry: ", $result->error ; 
Rich Graves <rcgraves@brandeis.edu>
UNet Systems Administrator