]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
ldap_get_connection() to return null when passed a config with bad user/pw.
authorJeffery To <jeffery.to@gmail.com>
Fri, 5 Mar 2010 09:54:53 +0000 (17:54 +0800)
committerCraig Andrews <candrews@integralblue.com>
Mon, 8 Mar 2010 18:14:41 +0000 (13:14 -0500)
This mainly affects login; before if the user enters a valid username
but invalid password, ldap_get_connection() throws an
LDAP_INVALID_CREDENTIALS error. Now the user sees the regular
"Incorrect username of password" error message.

plugins/LdapAuthentication/LdapAuthenticationPlugin.php
plugins/LdapAuthorization/LdapAuthorizationPlugin.php

index e0fd615ddaab89f959fbc93ad83f65c93f4d03e8..483209676575af0c1bb4c398b6c827124a1021a1 100644 (file)
@@ -224,6 +224,11 @@ class LdapAuthenticationPlugin extends AuthenticationPlugin
         $ldap->setErrorHandling(PEAR_ERROR_RETURN);
         $err=$ldap->bind();
         if (Net_LDAP2::isError($err)) {
+            // if we were called with a config, assume caller will handle
+            // incorrect username/password (LDAP_INVALID_CREDENTIALS)
+            if (isset($config) && $err->getCode() == 0x31) {
+                return null;
+            }
             throw new Exception('Could not connect to LDAP server: '.$err->getMessage());
         }
         if($config == null) $this->default_ldap=$ldap;
index 19aff42b8bb57a8a4e4c17677d6bc508ec3d3256..2608025ddc82975939e5669859226b0c99d3b041 100644 (file)
@@ -167,6 +167,11 @@ class LdapAuthorizationPlugin extends AuthorizationPlugin
         $ldap->setErrorHandling(PEAR_ERROR_RETURN);
         $err=$ldap->bind();
         if (Net_LDAP2::isError($err)) {
+            // if we were called with a config, assume caller will handle
+            // incorrect username/password (LDAP_INVALID_CREDENTIALS)
+            if (isset($config) && $err->getCode() == 0x31) {
+                return null;
+            }
             throw new Exception('Could not connect to LDAP server: '.$err->getMessage());
             return false;
         }