Matt Matt - 1 month ago 14
PHP Question

ldap_bind always returning true

I'm attempting to implement LDAP user authentification however for some reason no matter what the input is, ldap_bind always returns true. Whether the input is gibberish, empty, or legitimate

$ds = ldap_connect($ldaphost)
or die("Could not connect to $ds");

if($bind = ldap_bind($ds,$username, $password))
{
// login successful
}
else {
// error message
}


any ideas?

note: using the code below produces the same issue:

$bind = ldap_bind($ds,$username, $password);

if($bind)
{
// login successful
}
else {
// error message
}


Thanks in advance!

Answer

Just do like this...

 if(ldap_bind($ds,$username, $password))

instead of

if($bind = ldap_bind($ds,$username, $password))