Skip Menu |

This queue is for tickets about the perl-ldap CPAN distribution.

Report information
The Basics
Id: 54249
Status: resolved
Priority: 0/
Queue: perl-ldap

People
Owner: Nobody in particular
Requestors: lgoikhburg [...] griddynamics.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: One extra callback to subroutine in search method.
Date: Wed, 3 Feb 2010 15:01:20 +0300
To: bug-perl-ldap [...] rt.cpan.org
From: Lior Goikhburg <lgoikhburg [...] griddynamics.com>
When a callback subroutine is specified for the search method, it's called one extra time, after the last valid entry. It returns UNDEF for entry object and Success as result in this extra call. Can't find this behavior documented anywhere so assuming it's a bug. This happens in: Tested on: Linux 2.6.31 Net::LDAP 0.39 perl5 (revision 5 version 10 subversion 0) and also Linux 2.6.18 Net::LDAP 0.34 perl5 (revision 5 version 10 subversion 0) OpenLDAP: slapd 2.4.19 Code: #!/usr/bin/perl use strict; use Net::LDAP; my $ldap = Net::LDAP->new( 'ldap.server.company.com' ) or die "$@"; my $result = $ldap->bind ( "cn=user,dc=company,dc=com", password => "password", version => 3 ); $result = $ldap->search( base => "ou=container,dc=company,dc=com", filter => "(uid=*)", callback => \&process_entry ); $result = $ldap->unbind; sub process_entry { print "called\n"; } called is printed one extra time -- Regards, Lior Goikhburg
Subject: Re: [rt.cpan.org #54249] One extra callback to subroutine in search method.
Date: Wed, 3 Feb 2010 06:38:36 -0600
To: bug-perl-ldap [...] rt.cpan.org
From: Graham Barr <gbarr [...] pobox.com>
The callback is called for each packet received from the server. The server will send one packet per entry and then an "end of results" packet. The extra call you see is to signal the end of results, which is why $entry is undef. Thee is an example use in the FAQ http://search.cpan.org/dist/perl-ldap/lib/Net/LDAP/FAQ.pod#USING_THE_CALLBACK_SUBROUTINE_APPROACH
Subject: Re: [rt.cpan.org #54249] One extra callback to subroutine in search method.
Date: Wed, 3 Feb 2010 15:58:52 +0300
To: bug-perl-ldap [...] rt.cpan.org
From: Lior Goikhburg <lgoikhburg [...] griddynamics.com>
Hi, Graham. Thanks a lot for the quick reply and help, Looks like I missed the following piece of documentation: # # 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 print. return; } The situation is clear now. Thanks again. Lior.