AD does support paged results. This code is basically cut from an
example I found, and I use this structure:
my $page = Net::LDAP::Control::Paged->new( size => 100 );
my $cookie;
my $count = 0;
while (1) {
$mesg = $ldap->search(
base => "DC=example,DC=com",
filter => "(objectclass=user)",
control => [ $page ]
);
$mesg->code && die "Error on search: $@ : ".$mesg->error;
while ($adentry = $mesg->pop_entry()) {
//process
}
my($resp) = $mesg->control( LDAP_CONTROL_PAGED ) or last;
$cookie = $resp->cookie or last;
# Paging Control
$page->cookie($cookie);
}
if ($cookie) {
print "abnormal exit\n";
# We had an abnormal exit, so let the server know we do not want any more
$page->cookie($cookie);
$page->size(0);
$ldap->search( control => [ $page ] );
}
On Tue, Jul 1, 2008 at 3:23 AM, Chris Ridd <[EMAIL PROTECTED]> wrote:
>
> On 1 Jul 2008, at 07:52, Vartak, Yash V wrote:
>
>> Hey Chris I have tried that
>>
>> but it returns exactly no that a page size is set to, If you set the
>> page size to a value greater than admin limit it would return the amount
>> of entries <eq> to admin limit.
>>
>> logically I need the flow need to go this way
>>
>> {search first 999 entries}
>> <do processing>
>> {search next 1000 - 1999 entries}
>> <do processing>
>> ... continues till the time all the entries are processed
>>
>> What I am missing out is how to leave a pointer at 999 th entry
>>
>> Looks like I am making some mistake while implementing
>> Net::LDAP::Control::Paged
>
> Possibly. The man page shows you the loop that you have to write to get each
> page, which involves retrieving a cookie and reusing it in the next search,
> ie your "pointer". Did you also check if AD supports Paged Results?
>
> Cheers,
>
> Chris
>
--
--
Justin B. Alcorn