#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2009
    Posts
    2
    Rep Power
    0

    LDAP Perl showing only 500 entries.


    Hello all,
    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.

    #!/usr/bin/perl

    use Net::LDAP;

    $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);
    print "$errstr\n";
    }


    sub callback
    {
    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.
    return;
    }


    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.
    }
    }
    }

    $mesg->pop_entry;

    } # End of callback subroutine




    Thanks in advance....
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2009
    Location
    Charlotte, NC
    Posts
    111
    Rep Power
    9
    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.

IMN logo majestic logo threadwatch logo seochat tools logo