#!/usr/bin/perl -w use Data::Dumper; my $host = "bob.marlboro.edu"; my $managerEntry = "cn=Manager,dc=marlboro,dc=edu"; my $managerPasswd = "that-ldap-thing"; ### Gives "No SASL mechanism found #use Authen::SASL; #my $sasl = Authen::SASL->new( 'DIGEST-MD5', password=>$managerPasswd); #$ldap->bind($managerEntry, sasl=>$sasl); use Net::LDAP; my $result; my $ldap = Net::LDAP->new($host, version=>3) or die "Oops: $@"; $ldap->bind($managerEntry, password=>$managerPasswd); # -- add a person # These entries must match a strictly define, world-wide format. # See /usr/local/etc/openldap/slapd.conf and its included "schema", # like /usr/local/etc/openldap/schema/inetorgperson.schema my $uid = 'markf'; my $sn = 'Francillon'; my @names = ('Mark Francillon'); # could also include nick-names my $email = 'markf@marlboro.edu'; $result = $ldap->add( dn => "uid=$uid,ou=people,dc=gradcenter,dc=marlboro,dc=edu", attr => [ uid => $uid, cn => [@names], sn => $sn, mail => $email, objectclass => 'inetOrgPerson' ] ); warn("problem: " . $result->error . "\n") if $result->code;