//cache handler
protected $cache;
- //settings handler
+ /** @var Configuration settings handler **/
protected $configuration;
protected $doNotValidate = false;
$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;
}
* @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();
}
}
- try {
- $user = $this->createInstancyByUserName($id);
- return $user;
- } catch (\Exception $e) {
- return null;
- }
+ return $this->createInstancyByUserName($id);
}
}
* 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)) {
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;
}
/**