Properly catch and re-throw bind errors from Horde_Ldap.
authorJan Schneider <jan@horde.org>
Mon, 20 Sep 2010 09:22:35 +0000 (11:22 +0200)
committerJan Schneider <jan@horde.org>
Mon, 20 Sep 2010 09:30:19 +0000 (11:30 +0200)
framework/Auth/lib/Horde/Auth/Ldap.php

index 97c3946..d8dce3e 100644 (file)
@@ -218,13 +218,13 @@ class Horde_Auth_Ldap extends Horde_Auth_Base
         $dn = $this->_findDN($userId);
 
         /* Attempt to bind to the LDAP server as the user. */
-        $bind = clone $this->_ldap;
         try {
-            if (!$bind->bind($dn, $credentials['password'])) {
-                throw new Horde_Auth_Exception('', Horde_Auth::REASON_FAILED);
-            }
+            $this->_ldap->bind($dn, $credentials['password']);
         } catch (Horde_Ldap_Exception $e) {
-            throw new Horde_Auth_Exception('', Horde_Auth::REASON_FAILED);
+            if (Horde_Ldap::errorName($e->getCode() == 'LDAP_INVALID_CREDENTIALS')) {
+                throw new Horde_Auth_Exception('', Horde_Auth::REASON_BADLOGIN);
+            }
+            throw new Horde_Auth_Exception($e->getMessage(), Horde_Auth::REASON_MESSAGE);
         }
 
         if ($this->_params['password_expiration'] == 'yes') {