Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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

by MidLifeXis (Monsignor)
on May 23, 2016 at 20:20 UTC ( [id://1163903]=note: print w/replies, xml ) Need Help??


in reply to what is a pure perl equivalent for "net user username /domain"?

I second Discipulus's comment about Net::LDAP. I have a library that binds to my LDAP resource, receives usernames, and returns the current account status. Model is abstract enough that the top level application (the one that is driving the lookups) does not care that it is LDAP.

--MidLifeXis

  • Comment on Re: what is a pure perl equivalent for "net user username /domain"?

Replies are listed 'Best First'.
Re^2: what is a pure perl equivalent for "net user username /domain"?
by kwolcott (Novice) on May 23, 2016 at 20:47 UTC
    Thanks to both of you. The main reason why I asked this question is that my IT staff does not wish to share any LDAP server information with me and is reluctant to support my use of LDAP (I think they are afraid that I will find out some way to make changes when I only want to make queries and/or they concerned that I will consume network bandwidth and LDAP server resources). So I really don't know how to provide any information for my query other than the implicit ability to be on the domain (already logged in interactively) and know the username to query. So, I will look again at the LDAP example URL provided and hope that I can generate the query I need with the minimal information that I have. Ken
      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.

        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

Log In?
Username:
Password:

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

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

    No recent polls found