Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions apps/user_ldap/lib/Access.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public function extractRangeData($result, $attribute) {
}
return [];
}

/**
* Set password for an LDAP user identified by a DN
*
Expand Down Expand Up @@ -646,6 +646,8 @@ public function mapAndAnnounceIfApplicable(
if ($this->ncUserManager instanceof PublicEmitter && $isUser) {
$this->cacheUserExists($name);
$this->ncUserManager->emit('\OC\User', 'assignedUserId', [$name]);
} elseif (!$isUser) {
$this->cacheGroupExists($name);
}
return true;
}
Expand Down Expand Up @@ -749,6 +751,13 @@ public function cacheUserExists($ocName) {
$this->connection->writeToCache('userExists'.$ocName, true);
}

/**
* caches a group as existing
*/
public function cacheGroupExists(string $gid): void {
$this->connection->writeToCache('groupExists'.$gid, true);
}

/**
* caches the user display name
* @param string $ocName the internal Nextcloud username
Expand Down Expand Up @@ -938,7 +947,15 @@ public function batchApplyUserAttributes(array $ldapRecords){
* @return array
*/
public function fetchListOfGroups($filter, $attr, $limit = null, $offset = null) {
return $this->fetchList($this->searchGroups($filter, $attr, $limit, $offset), $this->manyAttributes($attr));
$groupRecords = $this->searchGroups($filter, $attr, $limit, $offset);
array_walk($groupRecords, function($record) {
$newlyMapped = false;
$gid = $this->dn2ocname($record['dn'][0], null, false, $newlyMapped, $record);
if(!$newlyMapped && is_string($gid)) {
$this->cacheGroupExists($gid);
}
});
return $this->fetchList($groupRecords, $this->manyAttributes($attr));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion apps/user_ldap/lib/Group_LDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ public function createGroup($gid) {
$uuid,
false
);
$this->access->connection->writeToCache("groupExists" . $gid, true);
$this->access->cacheGroupExists($gid);
}
}
return $dn != null;
Expand Down