如何使用Perl从LDAP服务器下载用户列表?

时间:2009-01-14 11:33:04

标签: perl ldap wiki

我想从我工作的LDAP服务器上传用户列表,以作为公司目录上传到我们的wiki。 如何使用Perl从LDAP服务器下载用户列表?

感谢。

1 个答案:

答案 0 :(得分:9)

使用NET::LDAP模块。

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