From: Gunnar Wrobel Date: Thu, 11 Mar 2010 07:11:19 +0000 (+0100) Subject: Adapt login handling to the newer Horde_Ldap class. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b667cc64a4355cf40675b8b31446b8cfff87c649;p=horde.git Adapt login handling to the newer Horde_Ldap class. --- diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap.php index c25fb3ef8..3d2d2b676 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap.php @@ -85,10 +85,23 @@ implements Horde_Kolab_Server_Interface { /** Do we need to switch the user? */ if ($guid !== $this->_guid) { - $this->_handleError( - $this->_conn->getRead()->bind($guid, $pass), - Horde_Kolab_Server_Exception::BIND_FAILED - ); + try { + $this->_conn->getRead()->bind($guid, $pass); + } catch (Horde_Ldap_Exception $e) { + if ($e->getCode() == 49) { + throw new Horde_Kolab_Server_Exception_Bindfailed( + 'Invalid username/password!', + Horde_Kolab_Server_Exception::BIND_FAILED, + $e + ); + } else { + throw new Horde_Kolab_Server_Exception( + 'Bind failed!', + Horde_Kolab_Server_Exception::BIND_FAILED, + $e + ); + } + } $this->_guid = $guid; } } diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/LdapTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/LdapTest.php index 585b953e4..97cc42130 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/LdapTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/LdapTest.php @@ -109,7 +109,7 @@ class Horde_Kolab_Server_Class_Server_LdapTest extends Horde_Kolab_Server_LdapTe { $this->ldap_read->expects($this->exactly(1)) ->method('bind') - ->will($this->returnValue(new PEAR_Error('Bind failed!'))); + ->will($this->throwException(new Horde_Ldap_Exception('Bind failed!'))); try { $this->server->connectGuid('test', 'test'); $this->fail('No exception!'); @@ -123,12 +123,12 @@ class Horde_Kolab_Server_Class_Server_LdapTest extends Horde_Kolab_Server_LdapTe { $this->ldap_read->expects($this->exactly(1)) ->method('bind') - ->will($this->returnValue(new PEAR_Error('Credentials invalid!', 49))); + ->will($this->throwException(new Horde_Ldap_Exception('Credentials invalid!', 49))); try { $this->server->connectGuid('test', 'test'); $this->fail('No exception!'); } catch (Horde_Kolab_Server_Exception_Bindfailed $e) { - $this->assertEquals('Credentials invalid!', $e->getMessage()); + $this->assertEquals('Invalid username/password!', $e->getMessage()); } }