From 7160d94e91142412ab7a8252effbd3b8764ad70e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Garc=C3=ADa=20S=C3=A1ez?= Date: Wed, 20 May 2015 18:32:44 +0200 Subject: [PATCH] Set domain before fetching auth sources In multidomain environment right now we are trying to authenticate against all sources defined in sogo.conf because the domain is not set at this point. In sogo.conf we have to specify the domain a source is useful for, so with this patch instead of 'n' tries of authentication we will perform only 1 (in a scenario where we have 1 source per domain, and we have 'n' domains). --- SoObjects/SOGo/SOGoUserManager.m | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/SoObjects/SOGo/SOGoUserManager.m b/SoObjects/SOGo/SOGoUserManager.m index 125ca3fcc..39c91ab60 100644 --- a/SoObjects/SOGo/SOGoUserManager.m +++ b/SoObjects/SOGo/SOGoUserManager.m @@ -425,9 +425,19 @@ static Class NSNullK; NSEnumerator *authIDs; NSString *currentID; BOOL checkOK; - + SOGoSystemDefaults *sd; + NSRange r; + checkOK = NO; - + + if (*domain == nil) + { + sd = [SOGoSystemDefaults sharedSystemDefaults]; + r = [login rangeOfString: @"@" options: NSBackwardsSearch]; + if ([sd enableDomainBasedUID] && r.location != NSNotFound) + *domain = [login substringFromIndex: (r.location + r.length)]; + } + authIDs = [[self authenticationSourceIDsInDomain: *domain] objectEnumerator]; while (!checkOK && (currentID = [authIDs nextObject])) {