From 9414df26c52fc9086233ff0110949dd6c1bf0116 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Garc=C3=ADa=20S=C3=A1ez?= Date: Wed, 29 Jul 2015 16:35:20 +0200 Subject: [PATCH] getUIDForEmail works on multidomain: returns login This method is used everywhere to try to retrieve the login of the user (and normally use the return value to [SOGoUser initwithLogin: ...]) In multidomain environments (with DomainLessLogin = false) there were several paths (mostly in SOGoAppointmentObject.m) that were trying to create SOGoUser objects with incorrect login: using only the uid part, not full email. Then like domain based uid was enabled, these users had DomainLessLogin set to true and further calls tried to authenticate only with the uid part (and they should not). This affects to several methods in: * ActiveSync/SOGoActiveSyncDispatcher.m * Appointments/SOGoAppointmentFolder.m * Appointments/SOGoAppointmentObject.m * Appointments/SOGoCalendarComponent.m * SOGoSAML2Session.m Probably a few features related with calendars are now fixed or working as intended in multidomain environments where the email is used as login --- SoObjects/SOGo/SOGoUserManager.m | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/SoObjects/SOGo/SOGoUserManager.m b/SoObjects/SOGo/SOGoUserManager.m index 127c6756c..af21f8635 100644 --- a/SoObjects/SOGo/SOGoUserManager.m +++ b/SoObjects/SOGo/SOGoUserManager.m @@ -394,11 +394,22 @@ static Class NSNullK; - (NSString *) getUIDForEmail: (NSString *) email { - NSDictionary *contactInfos; + NSDictionary *info; + SOGoSystemDefaults *sd; + NSString *uid, *domain; - contactInfos = [self contactInfosForUserWithUIDorEmail: email]; + info = [self contactInfosForUserWithUIDorEmail: email]; + uid = [info objectForKey: @"c_uid"]; - return [contactInfos objectForKey: @"c_uid"]; + sd = [SOGoSystemDefaults sharedSystemDefaults]; + if ([sd enableDomainBasedUID] + && ![[info objectForKey: @"DomainLessLogin"] boolValue]) + { + domain = [info objectForKey: @"c_domain"]; + uid = [NSString stringWithFormat: @"%@@%@", uid, domain]; + } + + return uid; } - (BOOL) _sourceChangePasswordForLogin: (NSString *) login