diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2012-08-28 14:24:31 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2012-08-28 14:24:50 +0200 |
commit | 42a996930481783af1a5a3fbbae18dc1201fbb0b (patch) | |
tree | 87198f8d4e39e89610d97f7396b70fe27f5c6156 /apps/user_ldap/user_ldap.php | |
parent | 549f69cbc1aafa13be6f011554ee82d26d814e52 (diff) | |
download | nextcloud-server-42a996930481783af1a5a3fbbae18dc1201fbb0b.tar.gz nextcloud-server-42a996930481783af1a5a3fbbae18dc1201fbb0b.zip |
LDAP: implement getHome() function, use either username (default) or specify an LDAP attribute value to use
Diffstat (limited to 'apps/user_ldap/user_ldap.php')
-rw-r--r-- | apps/user_ldap/user_ldap.php | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php index a97df7b4fd1..d297374600a 100644 --- a/apps/user_ldap/user_ldap.php +++ b/apps/user_ldap/user_ldap.php @@ -161,6 +161,44 @@ class USER_LDAP extends lib\Access implements \OCP\UserInterface { } /** + * @brief determine the user's home directory + * @param string $uid the owncloud username + * @return boolean + */ + private function determineHomeDir($uid) { + if(strpos($this->connection->homeFolderNamingRule, 'attr:') === 0) { + $attr = substr($this->connection->homeFolderNamingRule, strlen('attr:')); + $homedir = $this->readAttribute($this->username2dn($uid), $attr); + if($homedir) { + $homedir = \OCP\Config::getSystemValue( "datadirectory", \OC::$SERVERROOT."/data" ) . '/' . $homedir[0]; + \OCP\Config::setUserValue($uid, 'user_ldap', 'homedir', $homedir); + return $homedir; + } + } + + //fallback and default: username + $homedir = \OCP\Config::getSystemValue( "datadirectory", \OC::$SERVERROOT."/data" ) . '/' . $uid; + \OCP\Config::setUserValue($uid, 'user_ldap', 'homedir', $homedir); + return $homedir; + } + + /** + * @brief get the user's home directory + * @param string $uid the username + * @return boolean + */ + public function getHome($uid){ + if($this->userExists($uid)) { + $homedir = \OCP\Config::getUserValue($uid, 'user_ldap', 'homedir', false); + if(!$homedir) { + $homedir = $this->determineHomeDir($uid); + } + return $homedir; + } + return false; + } + + /** * @brief Check if backend implements actions * @param $actions bitwise-or'ed actions * @returns boolean @@ -169,7 +207,7 @@ class USER_LDAP extends lib\Access implements \OCP\UserInterface { * compared with OC_USER_BACKEND_CREATE_USER etc. */ public function implementsActions($actions) { - return (bool)(OC_USER_BACKEND_CHECK_PASSWORD & $actions); + return (bool)((OC_USER_BACKEND_CHECK_PASSWORD | OC_USER_BACKEND_GET_HOME) & $actions); } }
\ No newline at end of file |