使用Perl获取AD组用户

4

我一直在尝试打印出“域用户”中的所有成员。问题是,它只打印出其中的一小部分,然后就停止了。不确定原因。有人能解决这个问题吗?

#!/usr/bin/perl

 use Net::LDAP;

 my $uid = "cn=account,cn=users,dc=domain,dc=local";
 my $bindPass = "password";
 my $ldapServer = "ldap://server.domain.local";

 # connect to ldap server
 $ldap = Net::LDAP -> new ($ldapServer) || die "Could not connect to server\n";

 # bind to ldap server
 $ldap -> bind($uid, password => $bindPass);

 # search for group
 $mesg = $ldap -> search(filter => "(&(cn=Domain Users))", base => "dc=domain,dc=local");

 $entry = $mesg -> entry;
# @members = $entry -> get_value ('member;Range=0-*');
 #the above entry when uncommented doesn't work either.
@members = $entry -> get_value ('member');

 foreach $thing (@members) {
   print "$thing\n";
}
1个回答

1
Net::LDAP 文档中得知:

sizelimit => N

A sizelimit that restricts the maximum number of entries to be 
returned as a result of the search. A value of 0, and the default,
means that no restriction is requested. Servers may enforce a maximum
number of entries to return.

你的AD服务器可能已经配置了限制。尝试在搜索后检查$mesg->error()

如果你使用ldap://server.domain.local:3268/作为URL,你可能会更成功。AD在该端口上使用“迷你”ldap服务器与复制服务器通信(搜索“全局目录”);你在该服务器上看不到所有属性,但也许对最大条目数的限制较少。


那看起来很有前途,但最终都没有奏效。考虑可能是AD的问题。我们是在2008域上运行。我还会尝试研究服务器是否成为了瓶颈,如果是,如何改变。 - user3147432

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接