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

Hi; what is a pure perl equivalent for "net user username /domain"? I need to programmatically remove inactive accounts (defined as those no longer employed by the firm) and the mechanism I currently am using, via Perl on Cygwin is to run "net user username /domain" for every username that I have for the two applications for which I am responsible for account management. Is there a Pure Perl module that will return a yes/no answer to the question "is xyz currently an employee?" Thanks, Ken Wolcott
  • Comment on what is a pure perl equivalent for "net user username /domain"?

Replies are listed 'Best First'.
Re: what is a pure perl equivalent for "net user username /domain"?
by Discipulus (Canon) on May 23, 2016 at 19:10 UTC
    hello,

    Net::LDAP is the standard Perl way to access an LDAP, even ActiveDirectoy.

    The whole collection of modules show themselves at ldap.perl.org

    The collection contains also some specific tool to works with ActiveDirectory's peculiarities, but for basics tasks you just need a plain approach as for evey LDAP.

    As marto suggested you can profit also of Net::LDAP::FAQ Net::LDAP::Examples

    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.
Re: what is a pure perl equivalent for "net user username /domain"?
by MidLifeXis (Monsignor) on May 23, 2016 at 20:20 UTC

    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

      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.