Having problems using call back to dump a large number of computer accounts from w2k AD. When script is ran I get the following out put:

Ldap opened and starting search
at Call back, vaue passedin = Net::LDAP::Search=HASH(0x1e1626c)
No records found matching filter .
search done. processing
Error code: 83

However when I run the same search without using the NET::LDAP Page control, it returns the machine information upto the limit returned by AD (which is why I'm forced to use the PAGED option in the frist place).

Anyone notice any errors in the code that could be causing this?

Thanks

use Net::LDAP; use Net::LDAP::Control::Paged; use Net::LDAP::Constant qw( LDAP_CONTROL_PAGED ); #set paged fo +r later my $userID = 'Domain\\UsrID'; # <- your userid + here in the form DOMAIN\USERID; my $passwd = 'MyPassword';<br> # <- corres +ponding password here; $ldap = Net::LDAP->new('Server.lion.ad.haize.com') or die "$@"; my $result = $ldap->bind( dn => $userID, password => $passwd ); print "Ldap opened and starting search\n"; $mesg = $ldap->search( base => $base, scope => 'sub', filter => 'sAMAccountType=805306369', control => [ $page ], callback => \&callback, ); # # At this point the user needs to check the status of the # ldap search.; #; print "search done. processing \n"; if ( $mesg->code ) {; $errstr = $mesg->code; print "Error code: $errstr\n"; #$errstr = ldap_error_text($errstr); print "$errstr\n"; }; sub callback { print "at Call back, passed= @_ \n"; my ( $mesg, $entry) = @_; # # First you must check to see if something was returned. # Last execution of callback subroutine will have no # defined entry and mesg object # if ( !defined($entry) ) { print "No records found matching filter $match.\n" if ($mesg->count == 0) ; # if mesg is not defined nothing will pr +int. return; } my $dn = $entry->dn; # Obtain DN of this entry @attrs = $entry->attributes; # Obtain attributes for this entry. foreach my $var (@attrs) { #get a list of values for a given attribute $attr = $entry->get_value( $var, asref => 1 ); if ( defined($attr) ) { foreach my $value ( @$attr ) { print "$var: $value\n"; # Print each value for the attribute. } } } # # For large search requests the following 2 lines of code # may be very important, they will reduce the amount of memory # used by the search results. # # If the user is not worried about memory useage then the 2 lines # of code can be omitted. # $mesg->pop_entry; } # End of callback subroutine

Edit by tye, delete BR tags, add P and CODE tags


In reply to NET::LDAP (with Page control) error 83 returned from W2k search by grayone

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.