diff --git a/SoObjects/SOGo/SOGoUserManager.m b/SoObjects/SOGo/SOGoUserManager.m index 214cd46ba..be30095e1 100644 --- a/SoObjects/SOGo/SOGoUserManager.m +++ b/SoObjects/SOGo/SOGoUserManager.m @@ -410,7 +410,7 @@ static Class NSNullK; { NSDictionary *info; SOGoSystemDefaults *sd; - NSString *uid, *domain; + NSString *uid, *domain, *suffix; info = [self contactInfosForUserWithUIDorEmail: email]; uid = [info objectForKey: @"c_uid"]; @@ -420,7 +420,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; @@ -1051,8 +1055,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 2422cc8e9..6ca3b6215 100644 --- a/UI/MainUI/SOGoRootPage.m +++ b/UI/MainUI/SOGoRootPage.m @@ -231,7 +231,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