Code as follow:
Expand|Select|Wrap|Line Numbers
- #!/usr/bin/perl
- use strict;
- use warnings;
- use Net::LDAP;
- use Data::Dumper;
- use Net::LDAP::Util qw(ldap_error_name ldap_error_text);
- use Authen::SASL qw(Perl);
- my $ldap = Net::LDAP->new("1.1.1.1",port => 389,version => 3);
- my $sasl = Authen::SASL->new(
- mechanism => "DIGEST-MD5",
- callback =>{
- pass => "***",
- user => "***\@test.com"
- }
- );
- my $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";
- }
- ###--Add End---###
- if($ldap)
- {
- $ldap->unbind;
- }
- exit;
Return code: 49 Message: LDAP_INVALID_CREDENTIALS :The wrong password was supplied or the SASL credentials could not be processed
MessageID: 2 DN:
For "pass" and "user" match each other well, so the error may cauesd by SASL credentials, but i don't know the TRUE reason.
I appreciate Any advice, thanks.