Does FDS support Paged Results?
I ask this because with FDS configured with "nsslapd-sizelimit: 2000"
and a client search configured to return 1000 results per page it
appears that 2000 results are returned and a "Sizelimit exceeded" error
is returned by the server.
Attached is a perl snippet to test paged results.
Thanks,
Ben
use strict;
use Net::LDAP;
use Net::LDAP::Control::Paged;
use Net::LDAP::Constant qw( LDAP_CONTROL_PAGED );
my @server = ( "ldap2.example.com", "ldap3.example.com" );
my $base = "o=Company";
my $filter = "(|(objectClass=posixAccount)(objectClass=posixGroup))";
my $pagesize = 1000;
my $ldap = Net::LDAP->new( \@server, onerror => undef ) || die;
my $mesg = undef;
$mesg = $ldap->start_tls( verify => 'none' ) if $ldap;
$mesg = $ldap->bind(); # anonymous bind
# bind with username and password.
#
# $mesg = $ldap->bind( $userdn, password => $userpassword );
my $page = Net::LDAP::Control::Paged->new( size => $pagesize );
while (1) {
$mesg = $ldap->search(
base => $base,
filter => $filter,
scope => 'sub',
control => [$page],
callback => \&dosomething, # Subroutine to process each entry returned.
);
$mesg->code && die "ERROR: Search " . $base . ":(" . $mesg->error . ") " . $mesg->error;
# Get cookie from paged control
my ($resp) = $mesg->control(LDAP_CONTROL_PAGED) or last;
my $cookie = $resp->cookie or last;
# Set cookie in paged control
$page->cookie($cookie);
}
sub dosomething {
my ( $mesg, $entry ) = @_;
if ( !defined($entry) ) {
return;
}
elsif ( $entry->isa('Net::LDAP::Reference') ) {
return;
}
my @classes = $entry->get_value('objectClass');
if ( grep /organizationalUnit/i, @classes ) {
print $entry->dn() . " is an organizationalUnit.\n";
}
elsif ( grep /computer/i, @classes ) {
print $entry->dn() . " is an computer.\n";
}
elsif ( grep /person/i, @classes ) {
print $entry->dn() . " is an user.\n";
}
elsif ( grep /group/i, @classes ) {
print $entry->dn() . " is an group.\n";
}
else {
print $entry->dn() . " is an unknown type.\n";
print "objectClass: " . join ( ':', @classes ) . "\n";
$entry->dump();
}
}
--
Fedora-directory-users mailing list
Fedora-directory-users@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-directory-users