Re: Net::LDAP search of a DN

Chris Ridd <[email protected]> Thu, 19 May 2011 07:34:54 +0100
Newsgroups gmane.comp.lang.perl.modules.ldap
Message-ID <[email protected]>
On 18 May 2011, at 18:45, Brian Gaber wrote:

> This dn search of dn=cn=name,o=org works from a command line and returns all the attributes of the dn:
> 
> ldapsearch -h host -x -b "cn=name,o=org"
> 
> However, this Net::LDAP does not return anything:
> 
> $mesg = $ldap->search(base=>"cn=name,o=org");
> 
> I have also tried:
> 
> $mesg = $ldap->search(
>                               base  =>"cn=name,o=org",
>                               scope => 'base'
> );

You should explicitly add the other search arguments to search() that your ldapsearch command-line program is implicitly adding. One obvious one is the search filter - something like "(objectclass=*)" is common.

If that doesn't make a difference you will have to do some investigating and work out what your command-line program is actually sending. Maybe it has debug modes which will help; maybe your server's logs have useful info?

Chris