From: David B. <D.B...@ma...> - 2000-05-05 00:17:55
|
Howdy folks... I just joined the list, and have already checked the archives for the answer...no luck there... (seings the archives apparently don't exist yet on the new mailserver) I'm connecting to a Novell Netware 5 LDAP server (from a unix box), and need a few clues.... I wanted to know if anyone is using/used perl-ldap to communicate with netware 5? I'm going to(hopefully) use it to automatically generate large quantities of users (students - about 6000 of them ) from our primary sun solaris box (a propriety user database) into a Novell NDS (across about 12 different contexts (I mean ou's) ) ...(using netware 5's LDAP server functionality).... So far, I have borrowed POD example code, and managed to connect, bind, add, and delete user objects quite easily...but I can't get search to work. What to I have to provide as a filter in order to return all objects in a particular ou (or o)? When I unbind at the end of the script, I get the following error: "Can't call method "pdu" on an undefined value at /usr/lib/perl5/site_perl/5.005/Net/LDAP.pm line 536" Netware specific Q's: Is it possible to create users 'homefolders' using an ldap query? Thanks. David. P.S. In case you're interested, here's the test code I'm using... (add and remove both work like a charm!) ------------------------------------------------------------------------ #!/usr/bin/perl use Net::LDAP; print "setting up LDAP connection....\n"; $ldap = Net::LDAP->new('192.168.0.10') or die "dying: $@"; $ldap->bind ( # bind to a directory with dn and password dn => 'cn=admin, o=SGCS ', password => 'mypassword' ); print "\n"; print "attempting to create user....\n"; $shortusername = "testuser1"; $result = $ldap->add ( dn => 'cn='.$shortusername.',o=SGCS', attr => [ 'cn' => $shortusername, 'givenName' => 'givennametest', 'surname' => 'Surnametest', 'fullName' => 'Fullname test', 'groupMembership' => ['cn=everyone, o=SGCS','cn=testgroup, o=SGCS'], # don't forget to also add user to group when group added to user...not like here 'mail' => $shortusername.'@gucis.cit-student.gu.edu.au', 'objectclass' => ['top', 'person', 'organizationalPerson', 'inetOrgPerson' ], ] ); $result->code && warn "failed to add entry: ", $result->error ; $result->code || print "added entry successfully.\n "; print "\n"; print "attempting to search for users....\n"; $mesg = $ldap->search ( base => 'o=SGCS', filter => '(&(sn=Surnametest) (o=SGCS))', ); $mesg->code && warn "LDAP search failed:", $mesg->error; $mesg->code || print "LDAP search succeeded\n"; print "search results:\n"; foreach $entry ($mesg->all_entries) { $entry->dump;} print "\n"; print "attempting to remove user....\n"; $result = $ldap->delete ( dn => 'cn=testuser, o=SGCS', ); $result->code && warn "failed to delete entry: ", $result->error ; $result->code || print "deleted entry successfully. \n"; # unbind doesn't work! #print "unbind\n"; #$ldap->unbind; ------------------------------------------------------------------------ -------------------------------------------------------------------- David Bussenschutt Email: D.B...@ma... Senior Computing Support Officer & Systems Administrator/Programmer Location: Griffith University. Information Technology Services Brisbane Qld. Aust. (TEN bldg. rm 1.33) Ph:(07)38757079 -------------------------------------------------------------------- |