Loading lib/Command/SyncMissingUsersToCommon.php +3 −1 Original line number Diff line number Diff line Loading @@ -122,10 +122,12 @@ class SyncMissingUsersToCommon extends Command { $this->userManager->callForAllUsers(function (IUser $user) use ($ipAddress, $isDryRun, $output, &$stats) { $username = $user->getUID(); // Get user metadata from LDAP to obtain usernameWithoutDomain $userMetadata = $this->ldapConnectionService->getUserMetadata($username); $usernameWithoutDomain = $userMetadata['usernameWithoutDomain'] ?? $username; // Check if user is missing from common database // Strip legacy domain from username before checking in common DB $usernameWithoutDomain = $this->userService->stripLegacyDomainFromUsername($username); if ($this->userService->isUsernameTaken($usernameWithoutDomain)) { return; // Skip if already exists } Loading lib/Service/UserService.php +7 −0 Original line number Diff line number Diff line Loading @@ -490,4 +490,11 @@ class UserService { private function getDefaultQuota() { return $this->config->getSystemValueInt('default_quota_in_megabytes', 1024); } /** * Remove legacy domain from username if present */ public function stripLegacyDomainFromUsername(string $username): string { $legacyDomain = $this->config->getSystemValue('legacy_domain', ''); return str_ireplace('@' . $legacyDomain, '', $username); } } Loading
lib/Command/SyncMissingUsersToCommon.php +3 −1 Original line number Diff line number Diff line Loading @@ -122,10 +122,12 @@ class SyncMissingUsersToCommon extends Command { $this->userManager->callForAllUsers(function (IUser $user) use ($ipAddress, $isDryRun, $output, &$stats) { $username = $user->getUID(); // Get user metadata from LDAP to obtain usernameWithoutDomain $userMetadata = $this->ldapConnectionService->getUserMetadata($username); $usernameWithoutDomain = $userMetadata['usernameWithoutDomain'] ?? $username; // Check if user is missing from common database // Strip legacy domain from username before checking in common DB $usernameWithoutDomain = $this->userService->stripLegacyDomainFromUsername($username); if ($this->userService->isUsernameTaken($usernameWithoutDomain)) { return; // Skip if already exists } Loading
lib/Service/UserService.php +7 −0 Original line number Diff line number Diff line Loading @@ -490,4 +490,11 @@ class UserService { private function getDefaultQuota() { return $this->config->getSystemValueInt('default_quota_in_megabytes', 1024); } /** * Remove legacy domain from username if present */ public function stripLegacyDomainFromUsername(string $username): string { $legacyDomain = $this->config->getSystemValue('legacy_domain', ''); return str_ireplace('@' . $legacyDomain, '', $username); } }