- 論壇徽章:
- 0
|
謝謝提示. 已經(jīng)實現(xiàn)了. CPAN是看過, 但沒怎么看懂. 光注意到anonymous bind了.
又google了一堆跟bind相關(guān)的東西.
sub authenticate_user {
my $user_name = shift;
my $pass_word = shift;
my $ldap_host = shift;
my $base = shift;
my $ldap = Net::LDAP->new( $ldap_host );
my $search = $ldap->search( # Search for the user
base => $base,
scope => 'sub',
filter => "(&(uid=$user_name))",
attrs => ['dn']
);
my $user_dn = $search->entry->dn;
#print $user_dn, "\n";
my $response = $ldap->bind( $user_dn, password => $pass_word );
#print "Response is $response \n";
#If bind sucessfully, that means the password is correct.
if ( $response->error eq 'Success' ) {
return 'Success';
}
else {
return 'Fail';
}
}
回復(fù) 4# py
|
|