diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2018-11-27 17:06:48 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2018-11-27 17:07:59 +0100 |
commit | c32cc4a194532f531786c14b99edaee7fc872105 (patch) | |
tree | afb2458d400b12cde8ef64571f310647d036aaaf /apps/user_ldap/lib/Access.php | |
parent | c8cab74404feb6d48137bc6dba48192b9c4850dd (diff) | |
download | nextcloud-server-c32cc4a194532f531786c14b99edaee7fc872105.tar.gz nextcloud-server-c32cc4a194532f531786c14b99edaee7fc872105.zip |
cache users as existing after mapping
during login they might be cached as non-existing and cause an Exception
in the long run
reduces some duplication, too
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap/lib/Access.php')
-rw-r--r-- | apps/user_ldap/lib/Access.php | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php index 82947bd6868..6fe2c155416 100644 --- a/apps/user_ldap/lib/Access.php +++ b/apps/user_ldap/lib/Access.php @@ -609,26 +609,25 @@ class Access extends LDAPUtility { // outside of core user management will still cache the user as non-existing. $originalTTL = $this->connection->ldapCacheTTL; $this->connection->setConfiguration(['ldapCacheTTL' => 0]); - if(($isUser && $intName !== '' && !$this->ncUserManager->userExists($intName)) - || (!$isUser && !\OC::$server->getGroupManager()->groupExists($intName))) { - if($mapper->map($fdn, $intName, $uuid)) { - $this->connection->setConfiguration(['ldapCacheTTL' => $originalTTL]); - if($this->ncUserManager instanceof PublicEmitter && $isUser) { - $this->ncUserManager->emit('\OC\User', 'assignedUserId', [$intName]); - } - $newlyMapped = true; + if( $intName !== '' + && (($isUser && !$this->ncUserManager->userExists($intName)) + || (!$isUser && !\OC::$server->getGroupManager()->groupExists($intName)) + ) + ) { + $this->connection->setConfiguration(['ldapCacheTTL' => $originalTTL]); + $newlyMapped = $this->mapAndAnnounceIfApplicable($mapper, $fdn, $intName, $uuid, $isUser); + if($newlyMapped) { return $intName; } } - $this->connection->setConfiguration(['ldapCacheTTL' => $originalTTL]); + $this->connection->setConfiguration(['ldapCacheTTL' => $originalTTL]); $altName = $this->createAltInternalOwnCloudName($intName, $isUser); - if (is_string($altName) && $mapper->map($fdn, $altName, $uuid)) { - if ($this->ncUserManager instanceof PublicEmitter && $isUser) { - $this->ncUserManager->emit('\OC\User', 'assignedUserId', [$altName]); + if (is_string($altName)) { + if($this->mapAndAnnounceIfApplicable($mapper, $fdn, $altName, $uuid, $isUser)) { + $newlyMapped = true; + return $altName; } - $newlyMapped = true; - return $altName; } //if everything else did not help.. @@ -636,6 +635,23 @@ class Access extends LDAPUtility { return false; } + protected function mapAndAnnounceIfApplicable( + AbstractMapping $mapper, + string $fdn, + string $name, + string $uuid, + bool $isUser + ) :bool { + if($mapper->map($fdn, $name, $uuid)) { + if ($this->ncUserManager instanceof PublicEmitter && $isUser) { + $this->cacheUserExists($name); + $this->ncUserManager->emit('\OC\User', 'assignedUserId', [$name]); + } + return true; + } + return false; + } + /** * gives back the user names as they are used ownClod internally * @param array $ldapUsers as returned by fetchList() |