By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,244 Members | 1,260 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,244 IT Pros & Developers. It's quick & easy.

Got message 49 error when bind to LDAP server

P: 1
I am trying to bind to a LDAP server, but failed.
Code as follow:

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5. use Net::LDAP;
  6. use Data::Dumper;
  7. use Net::LDAP::Util qw(ldap_error_name  ldap_error_text);
  8. use Authen::SASL qw(Perl);
  9.  
  10. my $ldap = Net::LDAP->new("1.1.1.1",port => 389,version => 3);
  11. my $sasl = Authen::SASL->new(
  12.               mechanism => "DIGEST-MD5",
  13.               callback =>{
  14.                 pass => "***",
  15.                 user => "***\@test.com"
  16.               }
  17.              );
  18. my $bind = $ldap->bind(sasl => $sasl);
  19. if($bind->code)
  20. {
  21.     LDAPerror("Binding",$bind);    
  22. }
  23. else
  24. {
  25.     print "ok!\n";    
  26. }
  27. ###---Add for ERROR display--####
  28. sub LDAPerror
  29. {    
  30.       my ($from,$mesg) = @_;
  31.     print "Return code: ",$mesg->code ;
  32.       print "\tMessage: ", ldap_error_name($mesg->code);
  33.       print " :",        ldap_error_text($mesg->code);
  34.       print "MessageID: ",$mesg->mesg_id;
  35.       print "\tDN: ",$mesg->dn."\n";
  36. }
  37.  
  38. ###--Add End---###
  39.  
  40. if($ldap)
  41. {
  42.     $ldap->unbind;    
  43. }
  44. exit;
After running the script the result is:

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.
Mar 19 '08 #1
Share this Question
Share on Google+
1 Reply


nithinpes
Expert 100+
P: 410
I am trying to bind to a LDAP server, but failed.
Code as follow:

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5. use Net::LDAP;
  6. use Data::Dumper;
  7. use Net::LDAP::Util qw(ldap_error_name  ldap_error_text);
  8. use Authen::SASL qw(Perl);
  9.  
  10. my $ldap = Net::LDAP->new("1.1.1.1",port => 389,version => 3);
  11. my $sasl = Authen::SASL->new(
  12.               mechanism => "DIGEST-MD5",
  13.               callback =>{
  14.                 pass => "***",
  15.                 user => "***\@test.com"
  16.               }
  17.              );
  18. my $bind = $ldap->bind(sasl => $sasl);
  19. if($bind->code)
  20. {
  21.     LDAPerror("Binding",$bind);    
  22. }
  23. else
  24. {
  25.     print "ok!\n";    
  26. }
  27. ###---Add for ERROR display--####
  28. sub LDAPerror
  29. {    
  30.       my ($from,$mesg) = @_;
  31.     print "Return code: ",$mesg->code ;
  32.       print "\tMessage: ", ldap_error_name($mesg->code);
  33.       print " :",        ldap_error_text($mesg->code);
  34.       print "MessageID: ",$mesg->mesg_id;
  35.       print "\tDN: ",$mesg->dn."\n";
  36. }
  37.  
  38. ###--Add End---###
  39.  
  40. if($ldap)
  41. {
  42.     $ldap->unbind;    
  43. }
  44. exit;
After running the script the result is:

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.

The error certainly points out that credentials provided were wrong. May be you forgot to escape some special characters in username/password!
It is always preferable to use single-quotes over double-quotes, when you are passing literal string (without any substitutions). You can also avoid escaping all those special meaning characters.

Expand|Select|Wrap|Line Numbers
  1. callback =>{
  2.                 pass => 'password' ,
  3.                 user => 'user@domain.com' ,
  4.               }
  5.  
  6.  
Mar 20 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.