From 08f57f6ad527f0f0b55fbf43c69c3609bc389bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Garc=C3=ADa=20S=C3=A1ez?= Date: Wed, 23 Sep 2015 15:49:53 +0200 Subject: [PATCH] SOGoUserManager: get domain after authentication For multidomain source which has no domain defined, we get the domain from the username which must have @domain as suffix --- SoObjects/SOGo/SOGoUserManager.m | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/SoObjects/SOGo/SOGoUserManager.m b/SoObjects/SOGo/SOGoUserManager.m index fe81be52d..60f69f9a3 100644 --- a/SoObjects/SOGo/SOGoUserManager.m +++ b/SoObjects/SOGo/SOGoUserManager.m @@ -477,7 +477,24 @@ static Class NSNullK; } if (checkOK && *domain == nil) - *domain = [sogoSource domain]; + { + SOGoSystemDefaults *sd = [SOGoSystemDefaults sharedSystemDefaults]; + BOOL multidomainSource = [sd enableDomainBasedUID] && + [sogoSource domain] == nil; + if (multidomainSource) + { + NSArray *parts = [login componentsSeparatedByString: @"@"]; + if ([parts count] != 2) + { + [self errorWithFormat: @"Authenticated with multidomain source " + @"but login is not an email (%@).", login]; + return NO; + } + *domain = [parts objectAtIndex: 1]; + } + else + *domain = [sogoSource domain]; + } return checkOK; }