diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-09-28 15:38:49 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-09-28 15:38:49 +0200 |
commit | bf1057143cdff8ec289d9d766ab100d64d7ea45d (patch) | |
tree | 6c35d0d99a72f27a981a07c93f0ecbf600764cd4 /apps/user_ldap/lib | |
parent | 3efe1d3b24e65ed76d521c24b0cfe4e0ff2e7af5 (diff) | |
parent | 5144d26088b98685a37c73c776a9a47203efa68a (diff) | |
download | nextcloud-server-bf1057143cdff8ec289d9d766ab100d64d7ea45d.tar.gz nextcloud-server-bf1057143cdff8ec289d9d766ab100d64d7ea45d.zip |
Merge branch 'master' into routing
Conflicts:
apps/files/js/filelist.js
core/js/js.js
lib/ocs.php
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r-- | apps/user_ldap/lib/access.php | 59 | ||||
-rw-r--r-- | apps/user_ldap/lib/connection.php | 4 | ||||
-rw-r--r-- | apps/user_ldap/lib/jobs.php | 2 |
3 files changed, 42 insertions, 23 deletions
diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php index 089548a69ba..d855ae2a163 100644 --- a/apps/user_ldap/lib/access.php +++ b/apps/user_ldap/lib/access.php @@ -206,21 +206,17 @@ abstract class Access { $dn = $this->sanitizeDN($dn); $table = $this->getMapTable($isUser); if($isUser) { + $fncFindMappedName = 'findMappedUser'; $nameAttribute = $this->connection->ldapUserDisplayName; } else { + $fncFindMappedName = 'findMappedGroup'; $nameAttribute = $this->connection->ldapGroupDisplayName; } - $query = \OCP\DB::prepare(' - SELECT `owncloud_name` - FROM `'.$table.'` - WHERE `ldap_dn` = ? - '); - //let's try to retrieve the ownCloud name from the mappings table - $component = $query->execute(array($dn))->fetchOne(); - if($component) { - return $component; + $ocname = $this->$fncFindMappedName($dn); + if($ocname) { + return $ocname; } //second try: get the UUID and check if it is known. Then, update the DN and return the name. @@ -295,25 +291,48 @@ abstract class Access { return $this->ldap2ownCloudNames($ldapGroups, false); } + private function findMappedUser($dn) { + static $query = null; + if(is_null($query)) { + $query = \OCP\DB::prepare(' + SELECT `owncloud_name` + FROM `'.$this->getMapTable(true).'` + WHERE `ldap_dn` = ?' + ); + } + $res = $query->execute(array($dn))->fetchOne(); + if($res) { + return $res; + } + return false; + } + + private function findMappedGroup($dn) { + static $query = null; + if(is_null($query)) { + $query = \OCP\DB::prepare(' + SELECT `owncloud_name` + FROM `'.$this->getMapTable(false).'` + WHERE `ldap_dn` = ?' + ); + } + $res = $query->execute(array($dn))->fetchOne(); + if($res) { + return $res; + } + return false; + } + + private function ldap2ownCloudNames($ldapObjects, $isUsers) { if($isUsers) { - $knownObjects = $this->mappedUsers(); $nameAttribute = $this->connection->ldapUserDisplayName; } else { - $knownObjects = $this->mappedGroups(); $nameAttribute = $this->connection->ldapGroupDisplayName; } $ownCloudNames = array(); foreach($ldapObjects as $ldapObject) { - $key = \OCP\Util::recursiveArraySearch($knownObjects, $ldapObject['dn']); - - //everything is fine when we know the group - if($key !== false) { - $ownCloudNames[] = $knownObjects[$key]['owncloud_name']; - continue; - } - $ocname = $this->dn2ocname($ldapObject['dn'], $ldapObject[$nameAttribute], $isUsers); if($ocname) { $ownCloudNames[] = $ocname; @@ -385,7 +404,7 @@ abstract class Access { $sqlAdjustment = ''; $dbtype = \OCP\Config::getSystemValue('dbtype'); if($dbtype == 'mysql') { - $sqlAdjustment = 'FROM `dual`'; + $sqlAdjustment = 'FROM DUAL'; } $insert = \OCP\DB::prepare(' diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php index 1922e7ff1f2..bf65d9ad91c 100644 --- a/apps/user_ldap/lib/connection.php +++ b/apps/user_ldap/lib/connection.php @@ -258,7 +258,7 @@ class Connection { if(empty($this->config['ldapGroupFilter']) && empty($this->config['ldapGroupMemberAssocAttr'])) { \OCP\Util::writeLog('user_ldap', 'No group filter is specified, LDAP group feature will not be used.', \OCP\Util::INFO); } - if(!in_array($this->config['ldapUuidAttribute'], array('auto','entryuuid', 'nsuniqueid', 'objectguid'))) { + if(!in_array($this->config['ldapUuidAttribute'], array('auto','entryuuid', 'nsuniqueid', 'objectguid')) && (!is_null($this->configID))) { \OCP\Config::setAppValue($this->configID, 'ldap_uuid_attribute', 'auto'); \OCP\Util::writeLog('user_ldap', 'Illegal value for the UUID Attribute, reset to autodetect.', \OCP\Util::INFO); } @@ -357,4 +357,4 @@ class Connection { return true; } -}
\ No newline at end of file +} diff --git a/apps/user_ldap/lib/jobs.php b/apps/user_ldap/lib/jobs.php index aff519226c8..b265a8339ef 100644 --- a/apps/user_ldap/lib/jobs.php +++ b/apps/user_ldap/lib/jobs.php @@ -43,7 +43,7 @@ class Jobs { if(empty($actualGroups) && empty($knownGroups)) { \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – groups do not seem to be configured properly, aborting.', \OCP\Util::INFO); - \OCP\setAppValue('user_ldap', 'bgjUpdateGroupsLastRun', time()); + \OCP\Config::setAppValue('user_ldap', 'bgjUpdateGroupsLastRun', time()); return; } |