Re: can bind but cannot search?
| From: | Bing Du | Date: | Tue, 22 Nov 2005 15:52:04 +0000 |
| Subject: | Re: can bind but cannot search? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-226282@lists.php.net to get a copy of this message | ||
Bing Du wrote:
Hello all, The following script returns 'search failed...' after 'LDAP bind successful...'. == <?php $ldaprdn = "CN=John Smith,OU=Users,DC=Coll,DC=some,DC=edu"; $ldappass = "passwd"; $ds=ldap_connect("ad.coll.some.edu"); if ($ds) { echo "Binding ...<br />"; $r=ldap_bind($ds, $ldaprdn, $ldappass); if ($r) {I've figured out. Adding 'ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);' right after ldap_connect fixed the problem. Bingecho "LDAP bind successful...<br />";} else {echo "LDAP bind failed...<br />"; exit;} $filter = "(sAMAccountName=jsmith)"; $base = "DC=Coll,DC=some,DC=edu"; $sr=ldap_search($ds, $base, $filter); if ($sr) {echo "Search result is " . $sr . "<br />";} else {echo "search failed...<br />"; }} ?> == However, the following ldapsearch returns the result fine. % ldapsearch -h ad.coll.some.edu -s sub -b "dc=coll,dc=some,dc=edu" -x -D 'CN=John Smith,OU=Users,DC=Coll,DC=some,DC=edu' -W "samaccountname=jsmith" I'm in dark now and don't know where to look for more information on why ldap_search did not work. I'd appreciate any help. Bing