From: Graham B. <gb...@po...> - 2000-07-03 15:00:47
|
Does anyone know when a Paged search is complete ? ----- Forwarded message from "Allen, Robbie" <ra...@ci...> ----- From: "Allen, Robbie" <ra...@ci...> To: "'Graham Barr'" <gb...@po...> Subject: RE: Page or VLV control Date: Sun, 2 Jul 2000 12:49:13 -0700 X-Mailer: Internet Mail Service (5.5.2650.21) Yep, that's better. So here is the finished product that works for me: #----------------------------------------------------# use Net::LDAP; use Net::LDAP::Control; use Net::LDAP::Constant qw( LDAP_CONTROL_PAGED LDAP_CONTROL_SORTREQUEST ); ... $page = Net::LDAP::Control->new( LDAP_CONTROL_PAGED, size => 1000); $sort = Net::LDAP::Control->new( LDAP_CONTROL_SORTREQUEST, order => 'cn'); @args = ( base => "cn=subnets,cn=sites,cn=configuration,$BASE_DN", scope => "subtree", filter => "(objectClass=subnet)", control => [ $sort, $page ] ); while (($mesg = $LDAP->search( @args ))) { print_subnet($_) foreach $mesg->entries; last if $mesg->count < $page->size; ($resp) = $mesg->control( LDAP_CONTROL_PAGED ); $page->cookie($resp->cookie); } #----------------------------------------------------# The only question that still remains for me is the best way to determine a Paged search is complete. Above I just check to see if the mesg count is less than the page size, but seems like there should be a more intuitive approach. The search inside the while clause isn't a good check, because after the search completes, it starts over again from 1 (and continues), so the only way to break out of the loop is with the 'last' call. Thanks for working on this!!! This is the critical piece I was missing to start automating a lot of our Active Directory processes. Robbie Allen > -----Original Message----- > From: Graham Barr [mailto:gb...@po...] > Sent: Sunday, July 02, 2000 12:01 AM > To: Allen, Robbie > Subject: Re: Page or VLV control > > > Ah, OK. Try this new patch > > Graham. > > On Sat, Jul 01, 2000 at 08:32:35PM -0700, Allen, Robbie wrote: > > Works! At least for Paged and Sort, haven't tried VLV yet. > For some > > reason, when I used both Paged and Sort together, I also > had to 'use' > > SortResult.pm or else it complained that it couldn't find init: > > > > Can't locate object method "init" via package > > "Net::LDAP::Control::SortResult" a > > t /usr/SD/perl5.004_05/lib/site_perl/Net/LDAP/Control.pm line 78. > > > > Wasn't necessary though if I just used the Sort control by itself. > ----- End forwarded message ----- |