From 3259cb64a9131b5ffbf2a87a7eed34203617ea71 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 20 Nov 2019 15:14:18 +0100 Subject: [PATCH] uid can be false when the user record does not exit fixes not loading files app for users who got a share by the gone LDAP user Signed-off-by: Arthur Schiwon --- apps/user_ldap/lib/Group_LDAP.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/apps/user_ldap/lib/Group_LDAP.php b/apps/user_ldap/lib/Group_LDAP.php index 2ce35c8f0e..c7b8528df6 100644 --- a/apps/user_ldap/lib/Group_LDAP.php +++ b/apps/user_ldap/lib/Group_LDAP.php @@ -738,20 +738,24 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD if ($result === false) { \OCP\Util::writeLog('user_ldap', 'No uid attribute found for DN ' . $userDN . ' on '. $this->access->connection->ldapHost, ILogger::DEBUG); + $uid = false; + } else { + $uid = $result[0]; } - $uid = $result[0]; } else { // just in case $uid = $userDN; } - if(isset($this->cachedGroupsByMember[$uid])) { - $groups = array_merge($groups, $this->cachedGroupsByMember[$uid]); - } else { - $groupsByMember = array_values($this->getGroupsByMember($uid)); - $groupsByMember = $this->access->nextcloudGroupNames($groupsByMember); - $this->cachedGroupsByMember[$uid] = $groupsByMember; - $groups = array_merge($groups, $groupsByMember); + if($uid !== false) { + if (isset($this->cachedGroupsByMember[$uid])) { + $groups = array_merge($groups, $this->cachedGroupsByMember[$uid]); + } else { + $groupsByMember = array_values($this->getGroupsByMember($uid)); + $groupsByMember = $this->access->nextcloudGroupNames($groupsByMember); + $this->cachedGroupsByMember[$uid] = $groupsByMember; + $groups = array_merge($groups, $groupsByMember); + } } if($primaryGroup !== false) {