From 7ca0a7b5fb4548bc781197eee1c7aa24efd93567 Mon Sep 17 00:00:00 2001 From: Hivert Quentin Date: Tue, 29 Oct 2024 14:52:37 +0100 Subject: [PATCH] fix(users): when using multi-domains configuration, only request the apropriate usersources --- SoObjects/SOGo/SOGoUserManager.m | 37 ++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/SoObjects/SOGo/SOGoUserManager.m b/SoObjects/SOGo/SOGoUserManager.m index c265f29ad..13aad82a9 100644 --- a/SoObjects/SOGo/SOGoUserManager.m +++ b/SoObjects/SOGo/SOGoUserManager.m @@ -1093,24 +1093,29 @@ static const NSString *kObfuscatedSecondaryEmailKey = @"obfuscatedSecondaryEmail domain = nil; infos = nil; + //Try to get the domain from the uid + r = [uid rangeOfString: @"@" options: NSBackwardsSearch]; + if (r.location != NSNotFound) + { + // The domain is probably appended to the username; + // make sure it is a defined domain in the configuration. + domain = [uid substringFromIndex: (r.location + r.length)]; + if ([self isDomainDefined: domain]) + username = [uid substringToIndex: r.location]; + else + domain = nil; + } + sd = [SOGoSystemDefaults sharedSystemDefaults]; - if ([sd enableDomainBasedUID]) - { - r = [uid rangeOfString: @"@" options: NSBackwardsSearch]; - if (r.location != NSNotFound) - { - // The domain is probably appended to the username; - // make sure it is a defined domain in the configuration. - domain = [uid substringFromIndex: (r.location + r.length)]; - if ([self isDomainDefined: domain]) - username = [uid substringToIndex: r.location]; - else - domain = nil; - } - if (domain != nil) - infos = [self contactInfosForUserWithUIDorEmail: username + if (domain != nil) + { + if ([sd enableDomainBasedUID]) + infos = [self contactInfosForUserWithUIDorEmail: username inDomain: domain]; - } + else + infos = [self contactInfosForUserWithUIDorEmail: uid + inDomain: domain]; + } if (infos == nil) // If the user was not found using the domain or if no domain was detected,