Hello All!
So I have a simple search using page control via response cookies.
But for some strange reason, it just keeps searching as if it’s not seeing its own page cookie.
I was under the impression that:
my ($resp) = $search->control( LDAP_CONTROL_PAGED ) or last;
would return the number of results coming back from my paged query. Under a debugger, I see this:
main::get_from_ldap(./generic_audit.pl:82):
82: my ($resp) = $search->control( LDAP_CONTROL_PAGED ) or last;
DB<2> n
main::get_from_ldap(./generic_audit.pl:83):
83: $cookie = $resp->cookie or last;
DB<2> print Dumper $resp
$VAR1 = bless( {
'value' => '0��
����}&u�6��`�f)�Sm�r���ұב��ChO���'i���C
����c���IK���
~$����
�!�����INDEX_00000000�
�
����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������',
'type' => '1.2.840.113556.1.4.319',
'raw' => undef
}, 'Net::LDAP::Control::Paged' );
I’m a bit confused.
Can someone point out my error here?
Thanks All!
--Dan
My snippet (mostly lifted from the example):
use Net::LDAP;
use Net::LDAP::Control::Paged;
use Net::LDAP::Constant qw( LDAP_CONTROL_PAGED );
$ldap = AD::ldap_connect(…) unless $ldap;
my $page = Net::LDAP::Control::Paged->new( size => 900 );
sub get_from_ldap {
my $filter = shift;
my @entries;
my $cookie;
my @sargs = ( base => $base_dn,
scope => 'sub',
filter => $filter,
control => [ $page ] );
while(1) {
my $search = $ldap->search(@sargs);
# todo add check for $search->code to detect fail
push(@entries,$search->entries);
$search->code and last;
my ($resp) = $search->control( LDAP_CONTROL_PAGED ) or last;
$cookie = $resp->cookie or last;
# reset cookie in paged control
$page->cookie($cookie);
}
# clean up if last – probably don’t really have to do this but…
if ($cookie) {
$page->cookie($cookie);
$page->size(0);
$ldap->search(@sargs);
}
return (@entries);
}
my @entries = get_from_ldap(‘objectclass=user’);
…
Update:
Changing the page size to 100 seems to solve the situation.
I’m not sure why but I can live with the mystery.
I’ve got about 2800 objects so 28 queries is just fine.
Thanks anyway!
--Dan