Re: How to bind to AD?
Peter Karman <[email protected]> Sat, 13 Jun 2015 19:02:10 -0500
| Newsgroups | gmane.comp.lang.perl.modules.ldap |
|---|---|
| Message-ID | <[email protected]> |
Chris Ridd wrote on 6/13/15, 12:16 PM: > >> On 13 Jun 2015, at 12:30, Natxo Asenjo<[email protected]> wrote: >> But this *isn=E2=80=99t* the right way to check for bind failures. Bin= ds 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#H= ow_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 do= c takes care to show bind returning a $mesg, but it never does anything w= ith it. Perhaps that=E2=80=99s wrong. > > While I=E2=80=99m looking at the man page, I see references still to bi= gfoot.com and umich.edu! Maybe they should be replaced with something les= s obsolete - such as example.com. > +1 IMHO, it's a common mistake because the Net::LDAP syntax isn't consistent= with=20 idiomatic Perl as the language has evolved. Maybe if we're updating the d= ocs, we=20 could add a new interface that effectively adds something like: $ad->try( $ad->bind('**tried lots of stuff**', password =3D> '**passwo= rd**') ) or die $ad->error; which underneath does something effectively like: sub try { my $self =3D shift; my $msg =3D shift or confess "ldap_msg required"; return 1 unless $msg->code; $self->{__error} =3D join( "\n", "Return code: " . $msg->code, "Message: " . $msg->error_name, " :" . $msg->error_text, "MessageID: " . $msg->mesg_id, "DN: " . $msg->dn, ) . "\n"; return 0; } --=20 Peter Karman . http://peknet.com/ . [email protected]