Problems using perl Net::LDAP for paged results against Red Hat Directory Server

Solution Verified - Updated -

Issue

When using "Single paged results" ( RFC 2696 ) when running search queries on Red Hat Directory Server 9 using the perl module Net::LDAP ( as described in Red Hat Directory Server Admin Guide section 10.7.4 . Using Simple Paged Results ).

The perl code we use is the following:

this is the standaert code for "Single paging", nothing special.

what happens is that after a first page the programm stops, this means that the cookie is not received from the LDAP server the problem is in line:

$cookie    = $resp->cookie or last;

The loop is exited because the coockie is not received and this the following pages are not displayed and the paging does not work.

  • Sample Code (From man Net::LDAP::Control::Paged)
        use Net::LDAP;
        use Net::LDAP::Control::Paged;
        use Net::LDAP::Constant qw( LDAP_CONTROL_PAGED );

        $ldap = Net::LDAP->new( "ldap.mydomain.eg" );

        $page = Net::LDAP::Control::Paged->new( size => 100 );

        @args = ( base     => "cn=subnets,cn=sites,cn=configuration,$BASE_DN",
                  scope    => "subtree",
                  filter   => "(objectClass=subnet)",
                  callback => \&process_entry, # Call this sub for each entry
                  control  => [ $page ],
        );

        my $cookie;
        while (1) {
          # Perform search
          my $mesg = $ldap->search( @args );

          # Only continue on LDAP_SUCCESS
          $mesg->code  and last;

          # Get cookie from paged control
          my($resp)  = $mesg->control( LDAP_CONTROL_PAGED )  or last;
          $cookie    = $resp->cookie or last;

          # Set cookie in paged control
          $page->cookie($cookie);
        }

        if ($cookie) {
          # We had an abnormal exit, so let the server know we do not want any more
          $page->cookie($cookie);
          $page->size(0);
          $ldap->search( @args );
        }

We have tested the above code with other directory servers and with those directory servers, the code works without any problem.

Environment

  • Red Hat Enterprise Linux 6 & 7
  • Red Hat Directory Server (RHDS)
  • perl Net::LDAP

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content