develooper Front page | perl.ldap | Postings from February 2010

ldap search problem.

Thread Next
From:
Andrew Meng
Date:
February 6, 2010 16:02
Subject:
ldap search problem.
Message ID:
COL108-W577F7915FE85A8BCFE13FB8E540@phx.gbl

Hello,

 

LDAP search failed to return any result but I can get the result back using the same base and filter in ldp.exe. Here is the code:

 

!/usr/bin/perl


use Net::LDAP;

 

$ldap = Net::LDAP->new("server", port =>389) or die 'Could not contact LDAP server';

$ldap->bind("cn=id,DC=aa,DC=bb", password=>"password") or die 'Could not bind';

 

$mesg = $ldap->search(filter=>"(&(objectCategory=person)(objectClass=user)(sn=name))", 
 base=> "DC=aa,DC=bb",  attrs=> ['sAMAccountName'] );

 

@entries = $mesg->entries;

 

foreach $entry (@entries) {
        @attrs = $entry->attributes();
        foreach $attr (@attrs) {
                printf("\t%s: %s\n", $attr, $entry->get_value($attr));
        }
}


$ldap->unbind;

 

 

Does anyone know what is wrong?

 

Thanks a lot in advance!

Andrew
 		 	   		  
_________________________________________________________________



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About