schnibitz has asked for the wisdom of the Perl Monks concerning the following question:

Hi Everyone, The following code is supposed to return a list of users in the requested AD group. Problem is, it doesn't return all users, only a small fraction of them, like 9 or 10. What am I doing wrong?
#!/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 s +erver\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"; }
Thanks!

Replies are listed 'Best First'.
Re: NET::LDAP not returning all results
by NetWallah (Canon) on Dec 31, 2013 at 16:00 UTC
    Here are a few things to try (no guarantee they will help):

    use strict; # Always a good idea my $mesg = $ldap -> search(filter => "(cn=Domain Users)", # Take ou +t the & , since the filter has only ONE entity base => "dc=domain,dc=local", sizelimit=> 9999, # Try adding + this scope => "subtree" ); # Try adding + this die $mesg->error if $mesg->code; # Always error-check foreach my $entry ($mesg->entries) { $entry->dump; }
    Update: ALso try to search for ONLY Groups:
    filter => "(&(objectCategory=group)(cn=Domain Users))",
    I did not see an "entry" method in the object returned by LDAP search. Try "entries" as in my code above.

            If your eyes hurt after you drink coffee, you have to take the spoon out of the cup.
                  -Norm Crosby