From 3fa6f6f77c3045feffc16f33ad4014868b88de0c Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Tue, 16 Jun 2015 13:46:51 +0200 Subject: Hardening home folder retrieval in user_ldap * if the home folder naming rule is specified it should not fallback to the "use owncloud username as home folder" scenario * this does not allow the mixed setup of users with the attribute and some users without the attribute (which then would fallback to "use owncloud username as home folder" rule) anymore --- apps/user_ldap/user_ldap.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php index caff30a0e60..c4ebace8558 100644 --- a/apps/user_ldap/user_ldap.php +++ b/apps/user_ldap/user_ldap.php @@ -266,7 +266,8 @@ class USER_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn if($this->access->connection->isCached($cacheKey)) { return $this->access->connection->getFromCache($cacheKey); } - if(strpos($this->access->connection->homeFolderNamingRule, 'attr:') === 0) { + if(strpos($this->access->connection->homeFolderNamingRule, 'attr:') === 0 && + $this->access->connection->homeFolderNamingRule !== 'attr:') { $attr = substr($this->access->connection->homeFolderNamingRule, strlen('attr:')); $homedir = $this->access->readAttribute( $this->access->username2dn($uid), $attr); @@ -293,6 +294,8 @@ class USER_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn //TODO: if home directory changes, the old one needs to be removed. return $homedir; } + // a naming rule attribute is defined, but it doesn't exist for that LDAP user + throw new \Exception('Home dir attribute can\'t be read from LDAP for uid: ' . $uid); } //false will apply default behaviour as defined and done by OC_User -- cgit v1.2.3