Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

How do you check a 'bind' in LDAP?

by LittleGreyCat (Scribe)
on Sep 18, 2006 at 12:29 UTC ( [id://573535]=perlquestion: print w/replies, xml ) Need Help??

LittleGreyCat has asked for the wisdom of the Perl Monks concerning the following question:

Esteemed Monks

I am trying to learn Net::LDAP

I wrote a little ditty which worked, then stopped working.

I tracked the problem down to credentials.

I have been following the examples and use the form:

$ldap = Net::LDAP->new( 'ldap.umich.edu' ); # bind to a directory with dn and password $ldap->bind( 'cn=root, o=University of Michigan, c=us', password => 'secret' ) or die "Unable to bind $!\n";
The problem seems to be that if an authenticated bind fails, then an anonymous bind is allowed, so the 'bind' is successful (just not as successful as I hoped).

I have found a 'whoami' extension, in Net::LDAP::Extension::WhoAmI, but the directory I am binding to doesn't seem to support extensions.

So how do I check to see if I am bound as an anonymous or authenticated user?

TIA

Dave R

Nothing succeeds like a budgie with no teeth.

Replies are listed 'Best First'.
Re: How do you check a 'bind' in LDAP?
by hgolden (Pilgrim) on Sep 18, 2006 at 12:36 UTC
    Hey

    The object will hold the error code if there is one, so you can check it. Here's an excerpt from the FAQ: http://ldap.perl.org/FAQ.html

    "Most methods in Net::LDAP return a Net::LDAP::Message object, or a sub-class of that. This object will hold the results from the server, including the result code. So, for example, to determine the result of the bind operation.

    $mesg = $ldap->bind( $dn, password => $passwd ); if ( $mesg->code ) { # Handle error codes here }
    "

    Hope this helps,

    Hays

      Hays,

      Many thanks - I was just coming back to update my question with a "found it" because another bit I was reading just sank in.

      My code now has:

      $result->code && die "\nSomething bad happened : ", $result->error ;

      This works fine; I now feel dumb for not spotting it sooner.

      Cheers

      Dave R

      Nothing succeeds like a budgie with no teeth.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://573535]
Approved by wfsp
Front-paged by wfsp
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-19 11:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found