]> 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)
committerMorris Jobke <hey@morrisjobke.de>
Wed, 22 Apr 2015 09:32:58 +0000 (11:32 +0200)
apps/user_ldap/lib/connection.php
apps/user_ldap/lib/user/manager.php
apps/user_ldap/user_ldap.php

index 34a1cb39f9cd39be356fda6133aecf78457b1892..bbc710f5192b7d7227147f7d99606b746968c9dc 100644 (file)
@@ -45,7 +45,7 @@ class Connection extends LDAPUtility {
        //cache handler
        protected $cache;
 
-       //settings handler
+       /** @var Configuration settings handler **/
        protected $configuration;
 
        protected $doNotValidate = false;
@@ -158,7 +158,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->configuration->ldapHost, \OCP\Util::ERROR);
+                       throw new \Exception('Connection to LDAP server could not be established');
                }
                return $this->ldapConnectionRes;
        }
index 1bcc9b96d8ac15335f66fb034b043e7a5b25dd90..accbc14cffb87f8ba38001694e89c1eb54c055fe 100644 (file)
@@ -173,6 +173,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();
@@ -189,12 +190,7 @@ class Manager {
                        }
                }
 
-               try {
-                       $user = $this->createInstancyByUserName($id);
-                       return $user;
-               } catch (\Exception $e) {
-                       return null;
-               }
+               return $this->createInstancyByUserName($id);
        }
 
 }
index 609acdc0d78271283b9146a43483a5c92fec1c3f..3188a46ffa33c240121545750e75431a94d2efb4 100644 (file)
@@ -176,6 +176,7 @@ class USER_LDAP extends BackendUtility implements \OCP\UserInterface {
         * 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)) {
@@ -194,17 +195,12 @@ class USER_LDAP extends BackendUtility implements \OCP\UserInterface {
                        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;
        }
 
        /**