Skip to content

Commit 728d5de

Browse files
committed
fix: Cannot guess groupMemberAssocAttr from gid before creating group
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent 28893a0 commit 728d5de

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

lib/LDAPConnect.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ public function getDisplayNameAttribute(): string {
122122
return $this->ldapConfig->ldapUserDisplayName;
123123
}
124124

125+
public function getGroupMemberAssocAttribute(): string {
126+
return strtolower($this->ldapConfig->ldapGroupMemberAssocAttr);
127+
}
128+
125129
public function groupsEnabled(): bool {
126130
$filter = trim((string)$this->ldapConfig->ldapGroupFilter);
127131
$gAssoc = trim((string)$this->ldapConfig->ldapGroupMemberAssocAttr);

lib/LDAPGroupManager.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function createGroup($gid): ?string {
5353
* on passing an already inserted [ug]id, which we do not have at this point.
5454
*/
5555

56-
$newGroupEntry = $this->buildNewEntry($gid);
56+
$newGroupEntry = $this->buildNewEntry($gid, $this->ldapConnect->getGroupMemberAssocAttribute());
5757
$connection = $this->ldapConnect->getLDAPConnection();
5858
$newGroupDN = "cn=$gid," . $this->ldapConnect->getLDAPBaseGroups()[0];
5959
$newGroupDN = $this->ldapProvider->sanitizeDN([$newGroupDN])[0];
@@ -178,12 +178,11 @@ public function isLDAPGroup($gid): bool {
178178
}
179179
}
180180

181-
private function buildNewEntry(string $gid): array {
181+
private function buildNewEntry(string $gid, string $attribute): array {
182182
$entry = [
183183
'objectClass' => [],
184184
'cn' => $gid,
185185
];
186-
$attribute = strtolower($this->ldapProvider->getLDAPGroupMemberAssoc($gid));
187186
switch ($attribute) {
188187
case 'memberuid':
189188
case 'gidnumber':

0 commit comments

Comments
 (0)