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
13 changes: 10 additions & 3 deletions apps/user_ldap/lib/Access.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,18 +449,19 @@ public function username2dn($name) {
*
* @param string $fdn the dn of the group object
* @param string $ldapName optional, the display name of the object
* @param bool $autoMapping Should the group be mapped if not yet mapped
* @return string|false with the name to use in Nextcloud, false on DN outside of search DN
* @throws \Exception
*/
public function dn2groupname($fdn, $ldapName = null) {
public function dn2groupname($fdn, $ldapName = null, bool $autoMapping = true) {
//To avoid bypassing the base DN settings under certain circumstances
//with the group support, check whether the provided DN matches one of
//the given Bases
if (!$this->isDNPartOfBase($fdn, $this->connection->ldapBaseGroups)) {
return false;
}

return $this->dn2ocname($fdn, $ldapName, false);
return $this->dn2ocname($fdn, $ldapName, false, autoMapping:$autoMapping);
}

/**
Expand Down Expand Up @@ -490,10 +491,11 @@ public function dn2username($fdn, $ldapName = null) {
* @param bool $isUser optional, whether it is a user object (otherwise group assumed)
* @param bool|null $newlyMapped
* @param array|null $record
* @param bool $autoMapping Should the group be mapped if not yet mapped
* @return false|string with with the name to use in Nextcloud
* @throws \Exception
*/
public function dn2ocname($fdn, $ldapName = null, $isUser = true, &$newlyMapped = null, ?array $record = null) {
public function dn2ocname($fdn, $ldapName = null, $isUser = true, &$newlyMapped = null, ?array $record = null, bool $autoMapping = true) {
static $intermediates = [];
if (isset($intermediates[($isUser ? 'user-' : 'group-') . $fdn])) {
return false; // is a known intermediate
Expand All @@ -516,6 +518,11 @@ public function dn2ocname($fdn, $ldapName = null, $isUser = true, &$newlyMapped
return $ncName;
}

if (!$autoMapping) {
/* If no auto mapping, stop there */
return false;
}

//second try: get the UUID and check if it is known. Then, update the DN and return the name.
$uuid = $this->getUUID($fdn, $isUser, $record);
if (is_string($uuid)) {
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 @@ -1219,7 +1219,7 @@ protected function filterValidGroups(array $listOfGroups): array {
continue;
}
$name = $item[$this->access->connection->ldapGroupDisplayName][0] ?? null;
$gid = $this->access->dn2groupname($dn, $name);
$gid = $this->access->dn2groupname($dn, $name, false);
if (!$gid) {
continue;
}
Expand Down
Loading