How do I validate accounts using ldap?
If I try to bind the submited data I get this if the user enters a invalid password:
Quote:
Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server: Invalid credentials in
Printable View
How do I validate accounts using ldap?
If I try to bind the submited data I get this if the user enters a invalid password:
Quote:
Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server: Invalid credentials in
anyone?
edit: well I give up, I guess its a PHP bug...
What I ended up doing was reloading the page with php (header) when it detects a bad password then it displays wrong password error on that page... This method works seamlessly (in this case), but it doesnt feel right.
If you read the documentation, you will see that the function returns true on success and false on failure. Why not test the result and base your decision of what to do next on the result. Just a thought :ehh:
If you do not want the warning to be displayed then you can use the error suppression operator @:
PHP Code:@ldap_bind();
thats what I was doing :\
Here is my code, I get that error if I do not have that header.
but the error suppression operator was something I did not know about...PHP Code:$ldapbind = ldap_bind($ldapconn, "$username@X.org", $password);
if ($ldapbind)
{
//this will only EVER be seen if they do not have a samaccountname that matches there credentials
echo "Error, cannot find proper samaccountname...<br />";
}
else
{
echo "Invalid Password...<br />";
$_SESSION['LoginError']=true;
header("Location: " . $_SERVER['PHP_SELF']);
}
It's useful but use it only when you have no other option. Warnings in PHP usual indicate an abnormal condition in most cases this abnormal condition should never have occurred and may produce unpredictable results or errors further along in the script. In a few cases (only a few), the warnings produced are an indication of an abnormal condition but do not can be deal with, withing your code using error handlers.