Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: what is a pure perl equivalent for "net user username /domain"?

by Discipulus (Canon)
on May 23, 2016 at 21:16 UTC ( [id://1163906]=note: print w/replies, xml ) Need Help??


in reply to Re^2: what is a pure perl equivalent for "net user username /domain"?
in thread what is a pure perl equivalent for "net user username /domain"?

no fear! if you can issue the net user command you yet have rights to search via Net::LDAP

L in LDAP stands for lightweight so server resources and bandwidth are (generally) no more problems since decades.

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^4: what is a pure perl equivalent for "net user username /domain"?
by kwolcott (Novice) on May 24, 2016 at 01:50 UTC

    I'm getting a failure to bind, either of the anonymous or non-anonymous kind. Perhaps I chose the wrong LDAP server. I guessed what it was on the basis of a Google search where the suggestion was to do an nslookup.

    nslookup -type=srv _ldap._tcp.domain nslookup -type=srv _ldap._tcp.domain.tld (?)

    I got many replies, I chose one that sounded (phonetically) like it looked geographically compatible with my location in my domain.

    There's no error at the time of bind but the bind error occurs when I try to execute the search.

    script:

    #!/usr/bin/perl use strict; use warnings; use Net::LDAP; my $ldap_server = "svlitdc1.shoretel.com"; my $ldap = Net::LDAP->new($ldap_server) or die "$@"; my $mesg = $ldap->bind ('', password => '', version => 3) or die "FATA +L ERROR: LDAP bind did not succeed: $!\n"; my $username = "tienle"; $mesg = $ldap->search (base => "c=US", filter => "(&(sn=" . $usernam +e . ")(o=ShoreTel))"); $mesg->code && die $mesg->error; foreach my $entry ($mesg->entries) { $entry->dump; } $mesg = $ldap->unbind; print "Done!\n";

    Results:

    000004DC: LdapErr: DSID-0C0906E8, comment: In order to perform this op +eration a successful bind must be completed on the connection., data +0, v1db1 at ./ldap_try1.pl line 12, <DATA> line 751.
    Thanks, Ken
      format your code using <c>..</c> tags, THEN you can be permitted to read Simple LDAP / ActiveDirectory Authentication

      L*

      There are no rules, there are no thumbs..
      Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

      My local hive (or whatever it is called) requires me to bind with an active user before I am allowed to do lookups. Perhaps the anonymous bind is causing you issues.

      --MidLifeXis

        I tried specifying my username and password during the ldap bind command and it failed just like the anonymous bind.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1163906]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-25 13:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found