From: Jim H. <ha...@us...> - 2003-03-17 16:07:44
|
The problem is in the LDIF code. The following works: if ($searchobj){ $ldif = new Net::LDAP::LDIF("XX","a"); $ldif->write_entry($searchobj->entries()); $ldif->done(); } but it puts the results in file XX. Substituting - for XX doesn't send it to stdout. There is nothing in the docs to say that it should. You shouldn't need to use LDIF if you only want to display the results. There are lots of better ways. --Jim Harle On Mon, 17 Mar 2003, Chris Ridd wrote: > 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 > > > > ------------------------------------------------------- > This SF.net email is sponsored by:Crypto Challenge is now open! > Get cracking and register here for some mind boggling fun and > the chance of winning an Apple iPod: > http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en > |