2013/10/1 Paul Fontenot <ssdv6...@gmail.com>

> I am just beginning my foray into Perl with LDAP and I'm not getting what
> I expected to get from the LDAP server. If I use ldapsearch like this:
>
> ldapsearch -h ldap.example.com -p 389 -x -b "c=us"
>
> Then I recieve what I expect - everything below the basedn, however when I
> attempt the same thing ( I *think* I've written this correctly) in Perl I
> get the following error:
>
> "received LDAP error: No such object at ldap_crl.pl line 16, <DATA> line
> 749."
>
> Any direction would be greatly appreciated.
>
> #!/usr/bin/perl
> #
> use Net::LDAP;
>
> my $lsvr = 'ldap.example.com';
> my $ldap = Net::LDAP->new($lsvr)
>     or die "error connecting to $lsvr: $@";
>
> $ldap->bind;   # Bind anonymously, that is, no login and pass
>
> my $results = $ldap->search (                              # Perform a
> search for 'nvp'
>     filter => "(&(c=US))"
> );
>
> if($results->code) {
>     die "received LDAP error: @{[$results->error]}";
> }
>
> foreach my $entry ($results->all_entries) {
>     $entry->dump;
> }
>
> $ldap->unbind;   # Unbind and close connection
>


You use a base in ldapsearch and a filter in your code. Use 'base' in
search() to set the search base.


Clément.

Reply via email to