perl-ldap bind ERROR
perl-ldap bind ERROR
最近在用ldap模块连接数据库,总是搞不通。
代码如下:
use Net::LDAP;
use Data:umper;
use Net::LDAP::Util qw(ldap_error_name ldap_error_text);
use Authen::SASL qw(Perl);
$ldap = Net::LDAP->new("1.1.1.1",port => 389,version => 3);
$sasl = Authen::SASL->new(
mechanism => "DIGEST-MD5",
callback =>{
pass => "****",
user => "***\@test.com"
}
);
$bind = $ldap->bind(sasl => $sasl);
if($bind->code)
{
LDAPerror("Binding",$bind);
}
else
{
print "ok!\n";
}
###---Add for ERROR display--####
sub LDAPerror
{
my ($from,$mesg) = @_;
print "Return code: ",$mesg->code ;
print "\tMessage: ", ldap_error_name($mesg->code);
print " :", ldap_error_text($mesg->code);
print "MessageID: ",$mesg->mesg_id;
print "\tDN: ",$mesg->dn."\n";
#---
# Programmer note:
#
# "$mesg->error" DOESN'T work!!!
#
#print "\tMessage: ", $mesg->error;
#-----
}
###--Add End---###
运行后结果是:
Return code: 49 Message: LDAP_INVALID_CREDENTIALS :The wrong password was supplied or the SASL credentials could not be processed。
不知道什么原因,盼望高手指点。谢谢啦~