diff --git a/appinfo/info.xml b/appinfo/info.xml
index 88c8155f..bd765481 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -45,6 +45,7 @@ While theoretically any other authentication provider implementing either one of
OCA\User_SAML\Migration\CleanupRemovedConfig
+ OCA\User_SAML\Migration\TransferGroupMembers
diff --git a/lib/Migration/TransferGroupMembers.php b/lib/Migration/TransferGroupMembers.php
new file mode 100644
index 00000000..68e13424
--- /dev/null
+++ b/lib/Migration/TransferGroupMembers.php
@@ -0,0 +1,52 @@
+groupMigration->findGroupsWithLocalMembers();
+ if (empty($groupsToTreat)) {
+ return;
+ }
+ $hasError = false;
+ $output->startProgress(count($groupsToTreat));
+ foreach ($groupsToTreat as $gid) {
+ try {
+ if ($this->groupMigration->migrateGroupUsers($gid)) {
+ $this->groupMigration->cleanUpOldGroupUsers($gid);
+ }
+ } catch (Throwable $e) {
+ $hasError = true;
+ $this->logger->warning('Error while transferring group members of {gid}', ['gid' => $gid, 'exception' => $e]);
+ } finally {
+ $output->advance();
+ }
+ }
+ $output->finishProgress();
+ if ($hasError) {
+ $output->warning('There were errors while transferring group members to SAML groups. You may try later `occ saml:group-migration:copy-incomplete-members` later and check your nextcloud.log.');
+ }
+ }
+}