Re: How to bind to AD?
Natxo Asenjo <[email protected]> Sat, 13 Jun 2015 13:30:15 +0200
| Newsgroups | gmane.comp.lang.perl.modules.ldap |
|---|---|
| Message-ID | <CAHBEJzXuOCt+28bH3ybFih2WsL1ftZHndd6qfzaksKZHpMRRNA@mail.gmail.com> |
--089e01228bb273e4440518648c42 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Sat, Jun 13, 2015 at 11:47 AM, Chris Ridd <[email protected]> wrote: > > > On 11 Jun 2015, at 22:45, David Lee Lambert <[email protected]> wrote: > > > I've reduced my non-working code to the following... > > > > #! perl -w > > > > use Net::LDAP; > > my $ad =3D Net::LDAP->new('ad.**org**.com', debug =3D> 2) > > or die "Couldn't connect to AD: $@, $!"; > > $ad->bind('**tried lots of stuff**', password =3D> '**password**') > > or die "Couldn't bind: $@, $!=E2=80=9D; > > I think what you=E2=80=99re checking here is a failure to either construc= t the > bind operation or send the bind to the server. > > But this *isn=E2=80=99t* 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_ca= n_I_tell_when_the_server_returns_an_error,_bind%28%29_always_returns_true ? $mesg =3D $ldap->bind( $dn, password =3D> $passwd ); if ( $mesg->code ) { # Handle error codes here } > > This won=E2=80=99t solve your underlying problem with AD, but you might g= et more > of an idea what=E2=80=99s failing if you look at the bind result. > > this is a FAQ as well :-): http://search.cpan.org/~marschap/perl-ldap-0.65/lib/Net/LDAP/FAQ.pod#What_i= s_the_proper_format_of_the_bind_DN ? but as I replied earlier for AD ldap there are other options which are usually shorter. -- Groeten, natxo --089e01228bb273e4440518648c42 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo= te">On Sat, Jun 13, 2015 at 11:47 AM, Chris Ridd <span dir=3D"ltr"><<a h= ref=3D"mailto:[email protected]" target=3D"_blank">[email protected]</a>>= ;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0p= x 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span = class=3D""><br> > On 11 Jun 2015, at 22:45, David Lee Lambert <<a href=3D"mailto:davi= [email protected]">[email protected]</a>> wrote:<br> <br> > I've reduced my non-working code to the following...<br> ><br> > #! perl -w<br> ><br> > use Net::LDAP;<br> > my $ad =3D Net::LDAP->new('ad.**org**.com', debug =3D> 2= )<br> >=C2=A0 or die "Couldn't connect to AD: $@, $!";<br> > $ad->bind('**tried lots of stuff**', password =3D> '= **password**')<br> </span>>=C2=A0 or die "Couldn't bind: $@, $!=E2=80=9D;<br> <br> I think what you=E2=80=99re checking here is a failure to either construct = the bind operation or send the bind to the server.<br> <br> But this *isn=E2=80=99t* the right way to check for bind failures. Binds ar= e just another LDAP operation which returns a result, so you should check t= he result message like you do for search further down.<br></blockquote><div= ><br></div><div>exactly, and it turns out it is a FAQ ;-)<br><br><a href=3D= "http://search.cpan.org/~marschap/perl-ldap-0.65/lib/Net/LDAP/FAQ.pod#How_c= an_I_tell_when_the_server_returns_an_error,_bind%28%29_always_returns_true"= >http://search.cpan.org/~marschap/perl-ldap-0.65/lib/Net/LDAP/FAQ.pod#How_c= an_I_tell_when_the_server_returns_an_error,_bind%28%29_always_returns_true<= /a>?<br><br><pre class=3D""> <span class=3D"">$mesg</span> <span class=3D""= >=3D</span> <span class=3D"">$ldap</span><span class=3D"">-></span><span= class=3D"">bind</span><span class=3D"">(</span> <span class=3D"">$dn</span= ><span class=3D"">,</span> password <span class=3D"">=3D></span> <span c= lass=3D"">$passwd</span> <span class=3D"">);</span> <span class=3D"">if</span> <span class=3D"">(</span> <span class=3D"">$me= sg</span><span class=3D"">-></span>code <span class=3D"">)</span> <span = class=3D"">{</span> <span class=3D""># Handle error codes here</span> <span class=3D"">}</span></pre>=C2=A0</div><blockquote class=3D"gmail_quo= te" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204= );padding-left:1ex"> <br> This won=E2=80=99t solve your underlying problem with AD, but you might get= more of an idea what=E2=80=99s failing if you look at the bind result.<br> <span class=3D""></span><br></blockquote></div><br></div><div class=3D"gmai= l_extra">this is a FAQ as well :-):<br><br><a href=3D"http://search.cpan.or= g/~marschap/perl-ldap-0.65/lib/Net/LDAP/FAQ.pod#What_is_the_proper_format_o= f_the_bind_DN">http://search.cpan.org/~marschap/perl-ldap-0.65/lib/Net/LDAP= /FAQ.pod#What_is_the_proper_format_of_the_bind_DN</a>?<br><br></div><div cl= ass=3D"gmail_extra">but as I replied earlier for AD ldap there are other op= tions which are usually shorter.<br><br></div><div class=3D"gmail_extra"><d= iv class=3D"gmail_signature">--<br>Groeten,<br>natxo</div> </div></div> --089e01228bb273e4440518648c42--