Re: LDAP search

Quanah Gibson-Mount <[email protected]> Tue, 01 Oct 2013 14:16:34 -0700
Newsgroups gmane.comp.lang.perl.modules.ldap
Message-ID <DD100D7E4DD81EF26E74D69E@[192.168.1.93]>
--On Tuesday, October 01, 2013 9:19 PM +0100 Chris Ridd <[email protected]> 
wrote:

>
> On 1 Oct 2013, at 19:46, ClĂ©ment OUDOT <[email protected]> wrote:
>
>> You use a base in ldapsearch and a filter in your code. Use 'base' in
>> search() to set the search base.
>
> For Paul's benefit: what's happening here is that LDAP searches *require*
> that a search base is specified, a search scope is specified, and so on.
> There are no defaults for these parameters in the protocol.

Not quite true.  If you don't specify a scope, all LDAP servers I've dealt 
with default to sub.
You can see this with a basic script like:

#!/usr/bin/perl

use Net::LDAP;

my $ldap = Net::LDAP->new('serverbits');

$ldap->bind;

my $results=$ldap->search(base=>"", filter=>"(objectClass=*)");

foreach my $entry ($results->entries) {
  $entry->dump;
}

$ldap->unbind;

Results in:

Oct  1 14:14:28 zre-ldap004 slapd[18687]: conn=5835 op=1 SRCH base="" 
scope=2 deref=2 filter="(objectClass=*)"

But certainly, Net::LDAP won't search unless you specify both a base and a 
filter.

--Quanah




--

Quanah Gibson-Mount
Architect - Server
Zimbra Software, LLC
--------------------
Zimbra ::  the leader in open source messaging and collaboration