You are here: Re: can bind but cannot search? « PHP « IT news, forums, messages
Re: can bind but cannot search?

Posted by Bing Du on 11/22/05 17:52

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) {
> echo "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

I've figured out. Adding 'ldap_set_option($ds,
LDAP_OPT_PROTOCOL_VERSION, 3);' right after ldap_connect fixed the problem.

Bing

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация