Net::LDAP implements the following methods:
$ldap = Net::LDAP->new('ldap.my.domain', async => 1);
As for %options, you should give no more than one of the following:
my $dn = 'cn=Directory Manager'; my $password = 'adminpass'; my $sasl = Authn::SASL::stuff::here; $ldap->bind($dn, sasl => $sasl, version => 3);
$ldap->unbind;
$ldap->add($dn, attrs => [ 'uid' => 'nvp', 'cn' => ['Nathan Patwardhan', 'Enrico Pallazo'], 'gecos' => 'Nathan Patwardhan', 'loginShell' => '/usr/bin/bash' ] );
my $dn = q[uid=nvp,ou=People,o=my.domain]; $ldap->delete($dn);
$ldap->moddn($dn, newrdn => 'cn=Nate Patwardhan');
Values in the ARRAY are used in pairs; the first is the operation add, delete, or replace, and the second is a reference to an ARRAY of attribute values.
The attribute value list is also used in pairs. The first value in each pair is the attribute name, and the second is a reference to a list of values.
Use this form if you want to control the order in which the operations will be performed:
my $dn = q[uid=nvp,ou=People,o=my.domain]; $ldap->modify($dn, add => { sn => 'Patwardhan' } ); $ldap->modify($dn, delete => { 'weight' => '175' }); $ldap->modify($dn, replace => { 'loginShell' => '/usr/bin/tcsh' }); $ldap->modify( $dn, changes => [ add => [ sn => 'Patwardhan' ], delete => [ faxNumber => []], delete => [ weight => ['175']], replace => [ loginShell => '/usr/bin/tcsh'] ] );
If not specified, then the server will return the attributes that are specified as accessible by default given your bind credentials.
Certain additional attributes, such as createtimestamp, and other operational attributes may also be available for the asking:
$ldap->search( ... , attrs => ['createtimestamp'] , ... );
To retrieve the default attributes and additional ones, use "*":
my $base_dn = q[o=my.domain]; $mesg = $ldap->search( base => $base_dn, scope => 'sub', filter => '(|(objectclass=rfc822mailgroup)(sn=Patwardhan))' ); Net::LDAP::LDIF->new(\*STDOUT,"w")->write($mesg->entries);
$mesg = $ldap->search(@search_args); $ldap->abandon($mesg); # This could be written as $mesg->abandon
my $dn = q[uid=nvp,ou=People,o=my.domain]; $ldap->compare($dn, attr => 'cn', value => 'Nathan Patwardhan' );
The directory in capath must contain certificates named using the hash value of themselves. To generate these names, use OpenSSL in Unix, as follows:
ln -s cacert.pem 'openssl x509 -hash -noout < cacert.pem'.0
(assuming that the certificate of the CA is in cacert.pem).
print "Subject DN: " . $ldaps->certificate->subject_name . "\n";
Copyright © 2002 O'Reilly & Associates. All rights reserved.