From: Todd <net...@ch...> - 2002-11-12 19:32:21
|
I'm try to write a seb app that uses LDAP Simple Auth to authenticate users against our iPlanet directory. The Perl code is being executed on an Activestate/Win2k setup. Here is the code: #!/usr/bin/perl use Net::LDAP; use Net::LDAP::Util qw(ldap_error_text ldap_error_name ldap_error_desc); $uid = shift; $pass = shift; $ldap = Net::LDAP->new('directory-f5.vw.com') or die "$0"; $ldap->bind ; # an anonymous bind $mesg = $ldap->search ( # perform a search base => "dc=vw,dc=com", filter => "(uid=$uid)" ); $mesg->code && die $mesg->error; $entry = $mesg->entry(0); #should be the first and only entry $ldap->unbind; # take down session $dn = $entry->dn; print "$dn\n\n"; $mesg2 = $ldap->bind ( # bind to a directory with dn and password $dn, password => $pass, version => 3, callback => sub { $_[0]->shift_entry } ); LDAPError("Binding", $mesg2) if $mesg2->code(); exit 1 if $mesg2->code(); sub LDAPError { my ($from, $mesg) = @_; print STDERR "\n"; print STDERR "Return code: ", $mesg->code . "\n"; print STDERR "Message: ", ldap_error_name($mesg->code); print STDERR " : ", ldap_error_text($mesg->code); print STDERR "MessageID: ", $mesg->mesg_id . "\n"; print STDERR "DN: ", $mesg->dn; print STDERR "\n"; } =============== When I run it I get: E:\Inetpub\scripts>ldap.pl myid mypass uid=myid,ou=PROD-ABH-XYZ-COM,ou=internal,ou=xyzoa,dc=xyz,dc=com Return code: 1 Message: LDAP_OPERATIONS_ERROR : Server encountered an internal error MessageID: 4 DN: Under other versions of the code I get an I/O error. Any ideas? Thanks! -Todd |