summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2015-12-11 00:12:41 +0100
committerArthur Schiwon <blizzz@owncloud.com>2015-12-11 00:12:41 +0100
commit8c7930015644fdd3121dd8399c975b7d15bf40a7 (patch)
tree6dc9a66ad828cf11e1f79190ec4946ff20a50abf /apps/user_ldap
parentae6c3c15393aa928aa13f913b9e96cb642b66c2b (diff)
downloadnextcloud-server-8c7930015644fdd3121dd8399c975b7d15bf40a7.tar.gz
nextcloud-server-8c7930015644fdd3121dd8399c975b7d15bf40a7.zip
throw NoUserException in getHome when the requested user does not exist anymore
Diffstat (limited to 'apps/user_ldap')
-rw-r--r--apps/user_ldap/user_ldap.php30
1 files changed, 25 insertions, 5 deletions
diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php
index 0097dda89b5..fc62c168575 100644
--- a/apps/user_ldap/user_ldap.php
+++ b/apps/user_ldap/user_ldap.php
@@ -30,6 +30,7 @@
namespace OCA\user_ldap;
+use OC\User\NoUserException;
use OCA\user_ldap\lib\BackendUtility;
use OCA\user_ldap\lib\Access;
use OCA\user_ldap\lib\user\OfflineUser;
@@ -190,15 +191,18 @@ class USER_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
/**
* checks whether a user is still available on LDAP
+ *
* @param string|\OCA\User_LDAP\lib\user\User $user either the ownCloud user
* name or an instance of that user
* @return bool
+ * @throws \Exception
+ * @throws \OC\ServerNotAvailableException
*/
public function userExistsOnLDAP($user) {
if(is_string($user)) {
$user = $this->access->userManager->get($user);
}
- if(!$user instanceof User) {
+ if(is_null($user)) {
return false;
}
@@ -212,6 +216,10 @@ class USER_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
return false;
}
+ if($user instanceof OfflineUser) {
+ $user->unmark();
+ }
+
return true;
}
@@ -274,10 +282,13 @@ class USER_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
}
/**
- * get the user's home directory
- * @param string $uid the username
- * @return string|bool
- */
+ * get the user's home directory
+ *
+ * @param string $uid the username
+ * @return bool|string
+ * @throws NoUserException
+ * @throws \Exception
+ */
public function getHome($uid) {
if(isset($this->homesToKill[$uid]) && !empty($this->homesToKill[$uid])) {
//a deleted user who needs some clean up
@@ -295,6 +306,15 @@ class USER_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
}
$user = $this->access->userManager->get($uid);
+ if(is_null($user) || ($user instanceof OfflineUser && !$this->userExistsOnLDAP($user->getUID()))) {
+ throw new NoUserException($uid . ' is not a valid user anymore');
+ }
+ if($user instanceof OfflineUser) {
+ // apparently this user survived the userExistsOnLDAP check,
+ // we request the user instance again in order to retrieve a User
+ // instance instead
+ $user = $this->access->userManager->get($uid);
+ }
$path = $user->getHomePath();
$this->access->cacheUserHome($uid, $path);