Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I download a list of users from an LDAP server using Perl?

Tags:

perl

ldap

wiki

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.

like image 487
lamcro Avatar asked Jan 23 '23 22:01

lamcro


1 Answers

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
like image 184
David Schmitt Avatar answered Jan 29 '23 06:01

David Schmitt