diff --git a/SoObjects/SOGo/SOGoSession.m b/SoObjects/SOGo/SOGoSession.m index 9af654b90..73bbbfa5d 100644 --- a/SoObjects/SOGo/SOGoSession.m +++ b/SoObjects/SOGo/SOGoSession.m @@ -41,6 +41,7 @@ #include #import "SOGoSystemDefaults.h" +#import "SOGoUserManager.h" @implementation SOGoSession @@ -262,7 +263,7 @@ // The domain is probably appended to the username; // make sure it is defined as a domain in the configuration. *theDomain = [*theLogin substringFromIndex: (r.location + r.length)]; - if (![[sd domainIds] containsObject: *theDomain]) + if (![[SOGoUserManager sharedUserManager] isDomainDefined: *theDomain]) *theDomain = nil; } } diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index d81dcf52c..d84eb6188 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -165,7 +165,7 @@ // The domain is probably appended to the username; // make sure it is defined as a domain in the configuration. domain = [newLogin substringFromIndex: (r.location + r.length)]; - if ([[sd domainIds] containsObject: domain] && + if ([[SOGoUserManager sharedUserManager] isDomainDefined: domain] && ![sd enableDomainBasedUID]) newLogin = [newLogin substringToIndex: r.location]; diff --git a/SoObjects/SOGo/SOGoUserManager.h b/SoObjects/SOGo/SOGoUserManager.h index d30821108..5cf246d3a 100644 --- a/SoObjects/SOGo/SOGoUserManager.h +++ b/SoObjects/SOGo/SOGoUserManager.h @@ -58,6 +58,7 @@ - (NSArray *) sourceIDsInDomain: (NSString *) domain; - (NSArray *) authenticationSourceIDsInDomain: (NSString *) domain; - (NSArray *) addressBookSourceIDsInDomain: (NSString *) domain; +- (BOOL) isDomainDefined: (NSString *) domain; - (NSObject *) sourceWithID: (NSString *) sourceID; - (NSDictionary *) metadataForSourceID: (NSString *) sourceID; diff --git a/SoObjects/SOGo/SOGoUserManager.m b/SoObjects/SOGo/SOGoUserManager.m index 3846da9d8..9afd3a74c 100644 --- a/SoObjects/SOGo/SOGoUserManager.m +++ b/SoObjects/SOGo/SOGoUserManager.m @@ -305,6 +305,35 @@ static Class NSNullK; return sourceIDs; } +- (BOOL) isDomainDefined: (NSString *) domain +{ + NSEnumerator *allIDs; + NSArray *ids; + NSString *currentID, *sourceDomain; + SOGoSystemDefaults *sd; + + if (!domain) return NO; + + ids = [_sources allKeys]; + if ([ids containsObject: domain]) + // FIXME check SOGoMailDomain? + // Now source id is being considered as the domain + return YES; + + sd = [SOGoSystemDefaults sharedSystemDefaults]; + if ([sd enableDomainBasedUID]) + { + allIDs = [ids objectEnumerator]; + while ((currentID = [allIDs nextObject])) + { + sourceDomain = [[_sources objectForKey: currentID] domain]; + if (!sourceDomain) // source that can identify any domain + return YES; + } + } + + return NO; +} - (NSString *) displayNameForSourceWithID: (NSString *) sourceID { NSDictionary *metadata; @@ -932,7 +961,7 @@ static Class NSNullK; // The domain is probably appended to the username; // make sure it is a defined domain in the configuration. domain = [uid substringFromIndex: (r.location + r.length)]; - if ([[sd domainIds] containsObject: domain]) + if ([self isDomainDefined: domain]) username = [uid substringToIndex: r.location]; else domain = nil;