4

I want to upload a list of users from my work's LDAP server to upload into our wiki as a company directory. How can I download a list of users from an LDAP server using Perl?

Thanks.

1 Answer 1

9

Use the NET::LDAP module.

A little example from the POD:

use Net::LDAP;

$ldap = Net::LDAP->new( 'ldap.bigfoot.com' ) or die "$@";

$mesg = $ldap->bind ;    # an anonymous bind

$mesg = $ldap->search( # perform a search
                       base   => "c=US",
                       filter => "(&(sn=Barr) (o=Texas Instruments))"
                     );
$mesg->code && die $mesg->error;

foreach $entry ($mesg->entries) { $entry->dump; }

$mesg = $ldap->unbind;   # take down session
Sign up to request clarification or add additional context in comments.

3 Comments

what parameter should I put on the $ldap->search() to get all the users in the server?
that depends solely on the configuration of your server.
I am having some problems with code based on the example above. It looked like it was working but I realized my bind logon is failing. Then it defaults to anonymous. Is there a debug variable one can use to make sure its logging in?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.