Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.

Page control confusion

Skip to first unread message

Dan Cutler

Oct 7, 2014, 2:09:14 PM10/7/14

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:



82:           my ($resp)  = $search->control( LDAP_CONTROL_PAGED )  or last;

  DB<2> n


83:           $cookie    = $resp->cookie or last;

  DB<2> print Dumper $resp

$VAR1 = bless( {

                 'value' => '0��








                 '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!





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



      $search->code and last;

      my ($resp)  = $search->control( LDAP_CONTROL_PAGED )  or last;

      $cookie    = $resp->cookie or last;


      # reset cookie in paged control




   # clean up if last – probably don’t really have to do this but…

   if ($cookie) {





   return (@entries);



my @entries = get_from_ldap(‘objectclass=user’);


Dan Cutler

Oct 9, 2014, 9:30:02 AM10/9/14



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!



0 new messages