-----Original Message-----
From: Shekhawat Raj [mailto:[EMAIL PROTECTED] 
Sent: 24 May 2004 22:10
To: [EMAIL PROTECTED]
Subject: issue on Net::LDAP sasl issue on windows 2000.

> I am runninga simple win2k an getting the follwoing error> Please help

> me. thanks in advance
>
> ------------------
> Return code: 49 Message: LDAP_INVALID_CREDENTIALS :The wrong password 
> was supplied or the SASL creden
> MessageID: 1    DN: Total entries returned: 0
> ----------------------------
>
> _______code------------------
>
> #!/usr/bin/perl
>
> use strict;
> use Net::LDAP;
> use Authen::SASL;
> #use Net::LDAP::Constant qw(LDAP_CONTROL_PAGED);
> use Net::LDAP::Util qw( ldap_error_name
>                           ldap_error_text) ;
>
>
> my $ad = Net::LDAP->new("ddxmoline3.jdnet.deere.com") or die "Could 
> not connect!";
>
>
> my $mesg = $ad->bind("[EMAIL PROTECTED]", 
> password=>"<password>", version => 3);

This is a simple bind operation and is not a SASL bind - therefore you
must specify a DN - see the bind() section of Net::LDAP man page for
more details. 

To perform a SASL bind you must create a SASL object and pass that to
the bind() method, e.g.

my $sasl = Authen::SASL->new(
    mechanism => 'DIGEST-MD5',
    callback  => {
      user => 'prod-ts-email', 
      pass => "<password>",
    },
  );

my $mesg = $ldap->bind(sasl=>$sasl);

However to use Digest MD5 authentication you must have Windows AD 2003
and get the latest version of Authen::SASL::Perl::DIGEST_MD5 when it is
updated with the latest patches discussed on this DL.

>
>  if ( $mesg->code ) {
>         #
>         # if we've got an error... record it
>         #
>         LDAPerror("Searching",$mesg);
>         }
> # Declare the necessary search variables
>
> # What is the search base?
>
> my $searchbase = 'OU=TeamSite,OU=Apps,OU=Computer Center 
> Moline,DC=jdnet,DC=deere,DC=com';
>
> # What are we searching for?
>
> my $filter = "CN=dlrdocausjdcompassgeneralworkarea";
>
> # Which attributes should be returned?
>
> my $attrs = "mail";
>
> # Execute the search
>
> my $results = 
> $ad->search(base=>$searchbase,filter=>$filter,attrs=>$attrs);
>
> # How many entries returned?
> #print "Result:: $results->error \n";
>
>  if ( $results->code ) {
>         #
>         # if we've got an error... record it
>         #
>         LDAPerror("Searching",$results);
>         }
>
>
>     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;
>
> }
>
> my $count = $results->count;
>
> print "Total entries returned: $count\n";
>
>
>
> # Unbind from the server
>
> $ad->unbind;
>
>



Reply via email to