Page 1 of 1

ldapsearch returns results, ldap_search() does not.

Posted: Fri Jul 06, 2012 1:16 pm
by pickle
When running an ldapsearch command on the command line, it returns tons of results, whereas an equivalent (or so I think) query via PHP returns nothing.

ldapsearch command:

Code: Select all

 ldapsearch -Zx -H ldap://directory.host.ca -D [CREDENTIALS] -w [PASSWORD] -z 0 -l 0 - LLL -b "ou=people,dc=business,dc=ca" "(&(facultyCode=AU)(term=1380)" uid
PHP search:

Code: Select all

    //binding has already happened with the same credentials as used in the CLI command
    $filter = '(&(facultyCode=AU)(term="1380"))';
    $list   = ldap_search($conn,'ou=people,dc=business,dc=ca',$filter,array('uid'),0,0,0);
What am I missing?

Re: ldapsearch returns results, ldap_search() does not.

Posted: Fri Jul 06, 2012 5:14 pm
by Benjamin
Never used ldap. But I've run into issues where the CLI is using a different php.ini file. Anything turn up in error logs?

Re: ldapsearch returns results, ldap_search() does not.

Posted: Fri Jul 06, 2012 5:18 pm
by pickle
The CLI isn't using PHP at all. It's a direct OpenLDAP executable. The person that's helping me with this is using raw command line calls - I'm just trying to get my PHP code to give me the same results.

Re: ldapsearch returns results, ldap_search() does not.

Posted: Fri Jul 06, 2012 5:27 pm
by Benjamin

Re: ldapsearch returns results, ldap_search() does not.

Posted: Fri Jul 06, 2012 5:33 pm
by pickle
Thanks for that, but it doesn't really apply to me. I'm not getting an error. I'm getting a successful search result - just with zero records. If I change my filter to ask for, say, all users - I get expected results. I'm fairly certain my problem is that my filter - as seen by the ldap server - is different between the PHP call, and the raw ldapsearch CLI command.