From: Chris R. <chr...@ma...> - 2003-03-17 15:39:47
|
On 17/3/03 2:25 pm, Sheahan, John (PCLN-NW) <Joh...@pr...> wrote: > I am using basic code (straight out of the O'Reilly book) to do a bind and > search on my LDAP directory. I get no error messages and it always returns > successfully but always shows 0 entries found. I am able to successfully > search the LDAP structure from a browser and also able to successfully > search it using the ldapsearch commands as follows: > > ##### This works fine > /usr/local/bin/ldapsearch -x -b 'dc=Priceline,dc=com' '(uid=jsheahan)' > > ##### So does this, from a browser > ldap://172.21.81.101:389/o=People,dc=priceline,dc=com?cn,homephone,title,emp > loyeetype,mail,telephonenumber?sub? > > ##### Here is my basic code > > use Net::LDAP; > use Net::LDAP::LDIF; > > $server = "172.21.81.101"; > $port = "389"; > $basedn = "o=People,dc=priceline,dc=com"; > $scope = "sub"; > $passwd = "secret"; > $binddn = "cn=Manager,dc=priceline,dc=com"; > > > $c = new Net::LDAP($server, port=>$port) or die "Unable to connect to > $server: $@\n"; > > #$c->bind() or die "Unable to bind: $@\n"; > > $c->bind($binddn, password => $passwd) or die "Unable to bind: $@\n"; > $searchobj = $c->search(base => $basedn, scope => $scope, filter => > "uid=jsheahan"); Firstly these are three different search operations, so it is unreasonable to expect them to behave identically. Your "ldapsearch" search is like this (also make sure ldapsearch is talking to the same server!): $c->search(base => 'dc=Priceline,dc=com', scope => 'sub', filter => '(uid=jsheahan)'); Your "ldap://" search is like this: $c->search(base => 'o=People,dc=priceline,dc=com', scope => 'sub', filter => '(objectclass=*)', attrs => [qw(cn homephone title employeetype mail telephonenumber)]); > die "Bad Search, errorcode #".$searchobj->code() if $searchobj->code(); > > > #process the return values from search() > if ($searchobj){ > $ldif = new Net::LDAP::LDIF("-"); > $ldif->write($searchobj->entries()); $ldif->write is deprecated; use $ldif->write_entry instead. What does $searchobj->count() return? > $ldif->done(); > } Cheers, Chris |