aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2023-08-03 13:56:14 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-08-10 10:57:34 +0200
commit1026b2131c53d074cf71e8e3ca4766b0a1b4ead3 (patch)
treeb4d12c9251a93800469394824154c89f70a52726 /apps
parent42448c0d7898412261a8fc78a26e8450a8cd6ee5 (diff)
downloadnextcloud-server-1026b2131c53d074cf71e8e3ca4766b0a1b4ead3.tar.gz
nextcloud-server-1026b2131c53d074cf71e8e3ca4766b0a1b4ead3.zip
Fix check-group command for new groups
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/user_ldap/lib/Command/CheckGroup.php18
1 files changed, 12 insertions, 6 deletions
diff --git a/apps/user_ldap/lib/Command/CheckGroup.php b/apps/user_ldap/lib/Command/CheckGroup.php
index 48fe631a09b..d55b846020a 100644
--- a/apps/user_ldap/lib/Command/CheckGroup.php
+++ b/apps/user_ldap/lib/Command/CheckGroup.php
@@ -86,13 +86,15 @@ class CheckGroup extends Command {
try {
$this->assertAllowed($input->getOption('force'));
$gid = $input->getArgument('ocName');
+ $wasMapped = $this->groupWasMapped($gid);
if ($this->backend->getLDAPAccess($gid)->stringResemblesDN($gid)) {
$groupname = $this->backend->dn2GroupName($gid);
if ($groupname !== false) {
$gid = $groupname;
}
}
- $wasMapped = $this->groupWasMapped($gid);
+ /* Search to trigger mapping for new groups */
+ $this->backend->getGroups($gid);
$exists = $this->backend->groupExistsOnLDAP($gid, true);
if ($exists === true) {
$output->writeln('The group is still available on LDAP.');
@@ -113,7 +115,7 @@ class CheckGroup extends Command {
}
}
- public function onGroupCreatedEvent(GroupChangedEvent $event, OutputInterface $output): void {
+ public function onGroupCreatedEvent(GroupCreatedEvent $event, OutputInterface $output): void {
$output->writeln('<info>The group '.$event->getGroup()->getGID().' was added to Nextcloud with '.$event->getGroup()->count().' users</info>');
}
@@ -131,11 +133,15 @@ class CheckGroup extends Command {
/**
* checks whether a group is actually mapped
- * @param string $ocName the groupname as used in Nextcloud
+ * @param string $gid the groupname as passed to the command
*/
- protected function groupWasMapped(string $ocName): bool {
- $dn = $this->mapping->getDNByName($ocName);
- return $dn !== false;
+ protected function groupWasMapped(string $gid): bool {
+ $dn = $this->mapping->getDNByName($gid);
+ if ($dn !== false) {
+ return true;
+ }
+ $name = $this->mapping->getNameByDN($gid);
+ return $name !== false;
}
/**