Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

NET::LDAP (with Page control) error 83 returned from W2k search

by grayone (Initiate)
on Dec 05, 2003 at 16:03 UTC ( #312545=perlquestion: print w/replies, xml ) Need Help??

grayone has asked for the wisdom of the Perl Monks concerning the following question:

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?


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('') 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

Replies are listed 'Best First'.
Re: NET::LDAP (with Page control) error 83 returned from W2k search
by jlongino (Parson) on Dec 05, 2003 at 17:29 UTC
    I found out that Net::LDAP::Control::Paged is not supported under the Sun Directory Server (formerly iPlanet Directory Server). I don't know about W2K AD, but suspect it is supported. If you don't receive a timely reply here you might try joining the perl-LDAP mail list since they specialize in the Net::LDAP modules.

    You can verify whether it is supported or not by adding critical => 1 into the arguments for the Net::LDAP::Control::Paged->new statement.

    Update: After looking more closely at your code, it appears you haven't used the Paged->new method or defined $page. If you'd been using "strict" and "warnings" it would have been pointed out to you. You should clean up your code and include something similar to the following before you use the $page variable:

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


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://312545]
Approved by Thelonius
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2021-12-06 04:04 GMT
Find Nodes?
    Voting Booth?
    R or B?

    Results (31 votes). Check out past polls.