<code> #!/usr/local/bin/perl use strict; use warnings; use Net::LDAP; use Net::LDAP::Control::Paged; use Net::LDAP::Constant qw( LDAP_CONTROL_PAGED );
my $ldap = Net::LDAP->new( "host", version => 3 ); my $page = Net::LDAP::Control::Paged->new( size => 5 );
my @args = ( base => "DN",
scope => "subtree",
filter => "(surname=smith)",
control => [ $page ],
);my $cookie;
my $pagect = 0;
my $entryct = 0;
while ( my $results = $ldap->search( @args ) ) {
$pagect++;
print "pagect: $pagect\n";
$results->code and last; foreach my $entry ($results->entries) {
$entryct++;
print " $entryct: cn => '", $entry->get_value('cn'), "'\n";
}my ($response) = $results->control( LDAP_CONTROL_PAGED ) or last; $cookie = $response->cookie or last; $page->cookie($cookie); } </code>
My understanding is that the results should look somewhat like the following:
<desired output>
pagect: 1
1: cn => 'Betty L. Smith'
2: cn => 'Connie M Smith'
3: cn => 'Nelson L. Smith'
4: cn => 'Rhonda B. Smith'
5: cn => 'Sandra A. Smith'
pagect: 2
6: cn => 'Jason E. Smith'
7: cn => 'Amanda L. Smith'
8: cn => 'Shannon V. Smith'
9: cn => 'Jennifer E. Smith'
10: cn => 'Jennifer S. Smith'
pagect: 3
11: cn => 'Theresa M. Smith' </desired output>
but instead I get:
<real output>
pagect: 1
1: cn => 'Betty L. Smith'
2: cn => 'Connie M Smith'
3: cn => 'Nelson L. Smith'
4: cn => 'Rhonda B. Smith'
5: cn => 'Sandra A. Smith'
6: cn => 'Jason E. Smith'
7: cn => 'Amanda L. Smith'
8: cn => 'Shannon V. Smith'
9: cn => 'Jennifer E. Smith'
10: cn => 'Jennifer S. Smith'
11: cn => 'Theresa M. Smith' </real output>
Am I overlooking something simple? Thanks in advance for any advice,
Jim Longino Systems Analyst I University of South Alabama
