Chris Ridd wrote on 6/13/15, 12:16 PM:

On 13 Jun 2015, at 12:30, Natxo Asenjo<natxo.ase...@gmail.com>  wrote:

But this *isn’t* the right way to check for bind failures. Binds are just 
another LDAP operation which returns a result, so you should check the result 
message like you do for search further down.

exactly, and it turns out it is a FAQ ;-)

http://search.cpan.org/~marschap/perl-ldap-0.65/lib/Net/LDAP/FAQ.pod#How_can_I_tell_when_the_server_returns_an_error,_bind%28%29_always_returns_true?

It is quite a common mistake though. I know the synopsis in the main doc takes 
care to show bind returning a $mesg, but it never does anything with it. 
Perhaps that’s wrong.

While I’m looking at the man page, I see references still to bigfoot.com and 
umich.edu! Maybe they should be replaced with something less obsolete - such as 
example.com.


+1

IMHO, it's a common mistake because the Net::LDAP syntax isn't consistent with idiomatic Perl as the language has evolved. Maybe if we're updating the docs, we could add a new interface that effectively adds something like:

  $ad->try( $ad->bind('**tried lots of stuff**', password => '**password**') )
    or die $ad->error;

which underneath does something effectively like:

  sub try {
    my $self = shift;
    my $msg  = shift or confess "ldap_msg required";
    return 1 unless $msg->code;
    $self->{__error} = join( "\n",
        "Return code: " . $msg->code,
        "Message: " . $msg->error_name,
        " :" . $msg->error_text,
        "MessageID: " . $msg->mesg_id,
        "DN: " . $msg->dn,
        ) . "\n";
    return 0;
  }


--
Peter Karman  .  http://peknet.com/  .  pe...@peknet.com

Reply via email to