From 405703162e6380cfdd9c6665194e7d6268ded6ff Mon Sep 17 00:00:00 2001 From: Hivert Quentin Date: Tue, 12 Nov 2024 09:03:10 +0100 Subject: [PATCH] fix(users): when using multi-domains configuration, only request the apopriate usersources. --- SoObjects/SOGo/LDAPSource.m | 10 ++++++++++ SoObjects/SOGo/SOGoUserManager.m | 18 ++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/SoObjects/SOGo/LDAPSource.m b/SoObjects/SOGo/LDAPSource.m index 722ffd4e7..7c0259554 100644 --- a/SoObjects/SOGo/LDAPSource.m +++ b/SoObjects/SOGo/LDAPSource.m @@ -1434,6 +1434,16 @@ groupObjectClasses: (NSArray *) newGroupObjectClasses contacts = [NSMutableArray array]; + if(theDomain) + { + if ([_baseDN rangeOfString: @"%d"].location != NSNotFound) + { + s = [NSMutableString stringWithString: _baseDN]; + [s replaceOccurrencesOfString: @"%d" withString: theDomain options: 0 range: NSMakeRange(0, [s length])]; + ASSIGN(_baseDN, s); + } + } + if ([match length] > 0 || !_listRequiresDot) { ldapConnection = [self _ldapConnection]; diff --git a/SoObjects/SOGo/SOGoUserManager.m b/SoObjects/SOGo/SOGoUserManager.m index 13aad82a9..be9916bf7 100644 --- a/SoObjects/SOGo/SOGoUserManager.m +++ b/SoObjects/SOGo/SOGoUserManager.m @@ -1118,10 +1118,12 @@ static const NSString *kObfuscatedSecondaryEmailKey = @"obfuscatedSecondaryEmail } if (infos == nil) + { // If the user was not found using the domain or if no domain was detected, // search using the original uid. infos = [self contactInfosForUserWithUIDorEmail: uid inDomain: nil]; + } return infos; } @@ -1150,8 +1152,7 @@ static const NSString *kObfuscatedSecondaryEmailKey = @"obfuscatedSecondaryEmail if ([currentUser isKindOfClass: NSNullK]) currentUser = nil; - else if (!([currentUser objectForKey: @"emails"] - && [currentUser objectForKey: @"cn"])) + else if (!([currentUser objectForKey: @"emails"] && [currentUser objectForKey: @"cn"])) { // We make sure that we either have no occurence of a cache entry or // that we have an occurence with only a cached password. In the @@ -1168,6 +1169,19 @@ static const NSString *kObfuscatedSecondaryEmailKey = @"obfuscatedSecondaryEmail } else newUser = NO; + + if(!domain) + { + //No domain provided is there one? + NSRange r; + r = [uid rangeOfString: @"@" options: NSBackwardsSearch]; + if (r.location != NSNotFound) + { + domain = [uid substringFromIndex: (r.location + r.length)]; + if (![self isDomainDefined: domain]) + domain = nil; + } + } [self _fillContactInfosForUser: currentUser withUIDorEmail: aUID inDomain: domain];