Adapt login handling to the newer Horde_Ldap class.
authorGunnar Wrobel <wrobel@temple.(none)>
Thu, 11 Mar 2010 07:11:19 +0000 (08:11 +0100)
committerGunnar Wrobel <wrobel@temple.(none)>
Thu, 11 Mar 2010 07:11:19 +0000 (08:11 +0100)
framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap.php
framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/LdapTest.php

index c25fb3e..3d2d2b6 100644 (file)
@@ -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;
         }
     }
index 585b953..97cc421 100644 (file)
@@ -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());
         }
     }