使用perl获取AD组的用户

时间:2013-12-30 20:00:56

标签: perl active-directory

我一直试图打印出“域用户”中的所有成员。问题是,它只打印出一小部分,然后只是排序停止。不知道为什么。有人能解释一下这个问题吗?

#!/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 个答案:

答案 0 :(得分:1)

来自Net::LDAP文档:

  

sizelimit => Ñ

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/作为网址,则可能会取得更大成功。 AD在该端口上使用“迷你”ldap服务器与复制的服务器通信(谷歌“全球目录”);您不会在该服务器上看到所有属性,但可能对最大条目数的限制较少。

相关问题