Skip to content

Commit

Permalink
Merge pull request #18049 from nextcloud/backport/18030/stable15
Browse files Browse the repository at this point in the history
[stable15] uid can be false when the user record does not exit
  • Loading branch information
rullzer authored Nov 25, 2019
2 parents 128359f + 5fda1c3 commit 5a92c46
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions apps/user_ldap/lib/Group_LDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -738,20 +738,24 @@ public function getUserGroups($uid) {
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) {
Expand Down

0 comments on commit 5a92c46

Please sign in to comment.