Using perl to get users from the AD group

I am trying to get this to print all members in "domain users". The problem is that it only displays a small part of them, and then just sorted. I do not know why. Can someone shed light on the problem?

#!/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";
}
+4
source share
1 answer

From Net :: LDAP docs:

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.

Your AD server might be configured with a limit. Try checking $mesg->error()after a search.

, ldap://server.domain.local:3268/ URL-. AD "" ldap- (google "global catalog" ); , , , .

+1

All Articles