summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/user_ldap.php
diff options
context:
space:
mode:
authorThomas Mueller <thomas.mueller@tmit.eu>2013-02-11 21:42:27 +0100
committerThomas Mueller <thomas.mueller@tmit.eu>2013-02-11 21:42:27 +0100
commit037fcde1334d7b4d2bdeaaad0a71adc692b27ff8 (patch)
tree6f10b1a8d54cfea8cc3adf343de0bbf0f115f3d2 /apps/user_ldap/user_ldap.php
parentf58ed7a509da54fcd29e21dc6fc75528822157a4 (diff)
parent58e57151e51a02788377f761b183c15cd03b0ef0 (diff)
downloadnextcloud-server-037fcde1334d7b4d2bdeaaad0a71adc692b27ff8.tar.gz
nextcloud-server-037fcde1334d7b4d2bdeaaad0a71adc692b27ff8.zip
Merge branch 'master' into fixing-1424-master
Diffstat (limited to 'apps/user_ldap/user_ldap.php')
-rw-r--r--apps/user_ldap/user_ldap.php47
1 files changed, 22 insertions, 25 deletions
diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php
index 6aa8cd9b83c..0962756228c 100644
--- a/apps/user_ldap/user_ldap.php
+++ b/apps/user_ldap/user_ldap.php
@@ -171,40 +171,37 @@ class USER_LDAP extends lib\Access implements \OCP\UserInterface {
}
/**
- * @brief determine the user's home directory
- * @param string $uid the owncloud username
+ * @brief get the user's home directory
+ * @param string $uid the username
* @return boolean
*/
- private function determineHomeDir($uid) {
+ public function getHome($uid) {
+ $cacheKey = 'getHome'.$uid;
+ if($this->connection->isCached($cacheKey)) {
+ return $this->connection->getFromCache($cacheKey);
+ }
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);
+ if($homedir && isset($homedir[0])) {
+ $path = $homedir[0];
+ //if attribute's value is an absolute path take this, otherwise append it to data dir
+ //check for / at the beginning or pattern c:\ resp. c:/
+ if(
+ '/' == $path[0]
+ || (3 < strlen($path) && ctype_alpha($path[0]) && $path[1] == ':' && ('\\' == $path[2] || '/' == $path[2]))
+ ) {
+ $homedir = $path;
+ } else {
+ $homedir = \OCP\Config::getSystemValue('datadirectory', \OC::$SERVERROOT.'/data' ) . '/' . $homedir[0];
+ }
+ $this->connection->writeToCache($cacheKey, $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;
- }
+ //false will apply default behaviour as defined and done by OC_User
+ $this->connection->writeToCache($cacheKey, false);
return false;
}