From: Howard, M. J <Mic...@pn...> - 2000-08-07 16:23:54
|
Hello, I'm new to LDAP. I am trying to use it for authentication. How do I retrieve the dn using a uid? Here is the code I'm using. I can successfully bind anonymously and perform a search on the LDAP, however, I am not sure how to retrieve the DN. Could someone point me in the right direction? $ldap = Net::LDAP->new('[LDAP SERVER]') or die "$@"; $mesg = $ldap->bind; $base = "o=[my company], c=[country]"; my $result = $ldap->search( base => "$base", scope => "sub", filter => "uid = $user", ); my $dn = $result->dn(); $ldap->unbind; if ( $result->count != 0 ) { $mesg = $ldap->bind( dn => "$dn", password => "$sent_pw" ); $ldap->unbind; if ($mesg->code) { return "Failed - User Entered Incorrect password"; } else { return 0; } } else { return "Failed - You do not exist in the LDAP Server"; } Michael Howard Information Sciences and Engineering Pacific Northwest National Laboratory (509) 375-6981 ISB2 528 |