RE: [PHP] LDAP confusion
| From: | jblanchard at pocket dot com | Date: | Sun, 05 Mar 2006 00:15:37 +0000 |
| Subject: | RE: [PHP] LDAP confusion | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-231454@lists.php.net to get a copy of this message | ||
[snip]
> if(!$ds=ldap_connect("foo")){
> echo "did not connect";
> }else {
> echo "connection successful";
> }
> $un = "user";
> $upw = "pass";
> echo "connect result is " . $ds . "<br />";
> ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
> ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
>
> if ($ds) {
> echo "Binding ...";
> if(!$r=ldap_bind($ds, $un, $upd)){
> echo "unable to verify</br>";
> }else{
> echo "verified<br>";
> }
>
> The result is always "verified".
From the comments on www.php.net/ldap_bind:
I have found that if either of the valuse for user or password are
blank, or as in my case a typo resulted in a blank user as it was an
undefined variable, the ldap_bind() will just perform an anonymous
bind and return true!
You have:
$upw = "pass";
but using $upd in ldap_bind ...
if(!$r=ldap_bind($ds, $un, $upd)){
unless it's a typo in your example that could explain it. ?
[/snip]
It was a typo.
Anyhow, I guess if the connection to the server is anonymous in the
event of a bad username / pw combo I will still need to search the AD
for a match for authentication. I am still having a problem getting a
search to work.