December 21st, 2009, 10:19 PM
LDAP Perl showing only 500 entries.
I have an ldap with around 4 lakh entries. I want to view all of them done through perl. I ve written the below code but its showing only 500 entries. Am I doing anything wrong in this. Please help.
$ldap = Net::LDAP->new('localhost') or die "$@";
$mesg = $ldap->search(
base => "dc=dimdim,dc=com",
filter => "dc=*",
callback => \&callback,
if ( $mesg->code )
$errstr = $mesg->code;
print "Error code: $errstr\n";
$errstr = ldap_error_text($errstr);
my ( $mesg, $entry) = @_;
if ( !defined($entry) )
print "No records found matching filter $match.\n"
if ($mesg->count == 0) ; # if mesg is not defined nothing will print.
my $dn = $entry->dn; # Obtain DN of this entry
@attrs = $entry->attributes; # Obtain attributes for this entry.
foreach my $var (@attrs)
$attr = $entry->get_value( $var, asref => 1 );
if ( defined($attr) )
foreach my $value ( @$attr )
print "$var: $value\n"; # Print each value for the attribute.
} # End of callback subroutine
Thanks in advance....
January 19th, 2010, 05:56 PM
You have your filter set to "dc=*" so I'm wondering if you actually have 500 domain context entries defined? If the filter in the example is not the one your using and you are actually using a filter like "objectclass=*" and are still getting just 500 entries back then you need to check the RETURN sizelimit for the directory. it may be restricting the number of entries returned from a search to 500.