I am a bit confused. I clipped out your code and made two changes: host
(line 8) and search base (line 11) to talk to my directory. The code runs
the way you expected. (I am using perl 5.6.1 and Net::LDAP version
0.28). I am afraid that I am at a loos as to why you are not seeing the
right page breaks.
pagect: 7
31: cn => 'NOEL A SMITH'
32: cn => 'TIMOTHY R SMITH'
33: cn => 'CARRIE SMITH'
34: cn => 'Patricia Smith'
35: cn => 'Angela C Smith'
pagect: 8
36: cn => 'MELVIN SMITH'
37: cn => 'KEVIN SMITH'
38: cn => 'SCOTT G SMITH'
39: cn => 'DENISE M SMITH'
40: cn => 'MARGIE MAE SMITH'
B
Bob Goolsby
[EMAIL PROTECTED]
(925) 979-7579
Jim Longino <[EMAIL PROTECTED]>
07/22/2003 10:44 AM
To
Perl-ldap-dev Mailing List <[EMAIL PROTECTED]>
cc
Subject
Net::LDAP::Control::Paged problems
I spent a little time on this, but am not sure where the problem lies.
Maybe I don't understand the purpose of the module. Here is the code,
which is pretty similar to the example in the module documentation:
<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