]> source.dussan.org Git - nextcloud-server.git/commitdiff
do not hide exception when ldap server has a hiccup
authorJörn Friedrich Dreyer <jfd@butonic.de>
Tue, 31 Mar 2015 11:42:23 +0000 (13:42 +0200)
committerJörn Friedrich Dreyer <jfd@butonic.de>
Fri, 10 Apr 2015 07:12:37 +0000 (09:12 +0200)
apps/user_ldap/lib/connection.php
apps/user_ldap/lib/user/manager.php
apps/user_ldap/user_ldap.php

index 1577d9facb83ec22f1293c2967f8e8f36f5d12bb..3869f5da9c912aedea777aa1e52b42f8471366dd 100644 (file)
@@ -167,7 +167,8 @@ class Connection extends LDAPUtility {
                        $this->establishConnection();
                }
                if(is_null($this->ldapConnectionRes)) {
-                       \OCP\Util::writeLog('user_ldap', 'Connection could not be established', \OCP\Util::ERROR);
+                       \OCP\Util::writeLog('user_ldap', 'No LDAP Connection to server ' . $this->connection->ldapHost, \OCP\Util::ERROR);
+                       throw new \Exception('Connection to LDAP server could not be established');
                }
                return $this->ldapConnectionRes;
        }
index c0bc8ea62308be7a0224e87b4f3326e250cd6901..b99c9715e58200824ea5ef3cc3cf755e0f2af9b6 100644 (file)
@@ -165,6 +165,7 @@ class Manager {
         * @brief returns a User object by it's DN or ownCloud username
         * @param string the DN or username of the user
         * @return \OCA\user_ldap\lib\user\User|\OCA\user_ldap\lib\user\OfflineUser|null
+        * @throws \Exception when connection could not be established
         */
        public function get($id) {
                $this->checkAccess();
@@ -181,12 +182,7 @@ class Manager {
                        }
                }
 
-               try {
-                       $user = $this->createInstancyByUserName($id);
-                       return $user;
-               } catch (\Exception $e) {
-                       return null;
-               }
+               return $this->createInstancyByUserName($id);
        }
 
 }
index 54e14c093f393322638795d4c64327ae3586118f..cd8a2dd251c153b73f51abf7e75d45bde96b5ff0 100644 (file)
@@ -190,6 +190,7 @@ class USER_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
         * check if a user exists
         * @param string $uid the username
         * @return boolean
+        * @throws \Exception when connection could not be established
         */
        public function userExists($uid) {
                if($this->access->connection->isCached('userExists'.$uid)) {
@@ -208,17 +209,12 @@ class USER_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
                        return true;
                }
 
-               try {
-                       $result = $this->userExistsOnLDAP($user);
-                       $this->access->connection->writeToCache('userExists'.$uid, $result);
-                       if($result === true) {
-                               $user->update();
-                       }
-                       return $result;
-               } catch (\Exception $e) {
-                       \OCP\Util::writeLog('user_ldap', $e->getMessage(), \OCP\Util::WARN);
-                       return false;
+               $result = $this->userExistsOnLDAP($user);
+               $this->access->connection->writeToCache('userExists'.$uid, $result);
+               if($result === true) {
+                       $user->update();
                }
+               return $result;
        }
 
        /**