diff --git a/SoObjects/SOGo/SOGoUserManager.m b/SoObjects/SOGo/SOGoUserManager.m index 2b522a157..0e00a2be2 100644 --- a/SoObjects/SOGo/SOGoUserManager.m +++ b/SoObjects/SOGo/SOGoUserManager.m @@ -398,7 +398,7 @@ static Class NSNullK; { NSDictionary *info; SOGoSystemDefaults *sd; - NSString *uid, *domain; + NSString *uid, *domain, *suffix; info = [self contactInfosForUserWithUIDorEmail: email]; uid = [info objectForKey: @"c_uid"]; @@ -408,7 +408,11 @@ static Class NSNullK; && ![[info objectForKey: @"DomainLessLogin"] boolValue]) { domain = [info objectForKey: @"c_domain"]; - uid = [NSString stringWithFormat: @"%@@%@", uid, domain]; + suffix = [NSString stringWithFormat: @"@%@", domain]; + + // Don't add @domain suffix if it's already there + if (![uid hasSuffix: suffix]) + uid = [NSString stringWithFormat: @"%@%@", uid, suffix]; } return uid; @@ -1039,8 +1043,15 @@ static Class NSNullK; // multi-domain environments authenticating only with the UIDFieldName if ([sd enableDomainBasedUID] && !domain) { - cacheUid = [NSString stringWithFormat: @"%@@%@", cacheUid, [currentUser objectForKey: @"c_domain"]]; - [currentUser setObject: [NSNumber numberWithBool: YES] forKey: @"DomainLessLogin"]; + NSString *suffix; + + suffix = [NSString stringWithFormat: @"@%@", [currentUser objectForKey: @"c_domain"]]; + + if (![cacheUid hasSuffix: suffix]) + { + cacheUid = [NSString stringWithFormat: @"%@%@", cacheUid, suffix]; + [currentUser setObject: [NSNumber numberWithBool: YES] forKey: @"DomainLessLogin"]; + } } [self _retainUser: currentUser withLogin: cacheUid]; diff --git a/UI/MainUI/SOGoRootPage.m b/UI/MainUI/SOGoRootPage.m index b1c3ff2d0..9348da2f9 100644 --- a/UI/MainUI/SOGoRootPage.m +++ b/UI/MainUI/SOGoRootPage.m @@ -224,7 +224,7 @@ // has all the logic for this, so lets use it. if ([domain isNotNull]) { - username = [[SOGoUserManager sharedUserManager] getUIDForEmail: username]; + username = [[SOGoUserManager sharedUserManager] getUIDForEmail: username]; } authCookie = [auth cookieWithUsername: username