diff --git a/ChangeLog b/ChangeLog index d6c195f22..75914b443 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,27 @@ -2011-07-15 Francis Lachapelle +2011-07-18 Francis Lachapelle - * SoObjects/SOGo/SOGoUser.m (-initWithLogin:roles:trust:): when - the login contains a @ character, compare the right part with only the - defined login domains (SOGoLoginDomains) -- don't consider all domains. + * SoObjects/SOGo/SOGoSystemDefaults.m (-addDomainToUID): new + method that returns the boolean value of the new system defaults + SOGoAddDomainToUID if at least one domain is defined. + + * SoObjects/SOGo/SOGoUser.m (-initWithLogin:roles:trust:): we now + try to extract the domain part of the login name only if the new + system defaults SOGoAddDomainToUID is set to YES. + + * SoObjects/SOGo/SOGoUserManager.m + (-contactInfosForUserWithUIDorEmail): idem. + + * SoObjects/SOGo/SOGoSession.m + (+decodeValue:usingKey:login:domain:password:): idem. + + * SoObjects/SOGo/SOGoUserManager.m + (-_sourceCheckLogin:andPassword:domain:perr:expire:grace:): the + domain argument is now a pointer so it will be set according to + the matching authentication source. + + * UI/MainUI/SOGoUserHomePage.m (-usersSearchAction): only append + the domain to the user's login if the new system defaults + SOGoAddToDomainToUID is set to YES. 2011-07-15 Wolfgang Sourdeau diff --git a/Documentation/SOGo Installation Guide.odt b/Documentation/SOGo Installation Guide.odt index 75360e001..93bd0d89c 100644 Binary files a/Documentation/SOGo Installation Guide.odt and b/Documentation/SOGo Installation Guide.odt differ diff --git a/SoObjects/SOGo/SOGoDAVAuthenticator.m b/SoObjects/SOGo/SOGoDAVAuthenticator.m index 44f740764..0755c223c 100644 --- a/SoObjects/SOGo/SOGoDAVAuthenticator.m +++ b/SoObjects/SOGo/SOGoDAVAuthenticator.m @@ -53,18 +53,20 @@ - (BOOL) checkLogin: (NSString *) _login password: (NSString *) _pwd { + NSString *domain; SOGoSystemDefaults *sd; SOGoCASSession *session; SOGoPasswordPolicyError perr; int expire, grace; BOOL rc; + domain = nil; perr = PolicyNoError; rc = ([[SOGoUserManager sharedUserManager] checkLogin: [_login stringByReplacingString: @"%40" withString: @"@"] password: _pwd - domain: nil + domain: &domain perr: &perr expire: &expire grace: &grace] diff --git a/SoObjects/SOGo/SOGoDefaults.plist b/SoObjects/SOGo/SOGoDefaults.plist index 8acd155df..7b3e4cc9f 100644 --- a/SoObjects/SOGo/SOGoDefaults.plist +++ b/SoObjects/SOGo/SOGoDefaults.plist @@ -29,6 +29,7 @@ SOGoWebAccessEnabled = YES; SOGoCalendarDAVAccessEnabled = YES; SOGoAddressBookDAVAccessEnabled = YES; + SOGoAddDomainToUID = NO; SOGoLoginModule = "Mail"; SOGoLanguage = "English"; @@ -38,15 +39,13 @@ "Russian", "Ukrainian", "Swedish"); SOGoTimeZone = "UTC"; - SOGoDayStartTime = "8"; SOGoDayEndTime = "18"; SOGoTimeFormat = "%H:%M"; - - SOGoIMAPServer = "localhost"; SOGoFirstDayOfWeek = 0; SOGoFirstWeekOfYear = "January1"; + SOGoIMAPServer = "localhost"; SOGoMailDomain = "localhost"; SOGoMailMessageCheck = "manually"; SOGoMailMessageForwarding = "inline"; @@ -57,7 +56,6 @@ SOGoMailListViewColumnsOrder = ( "Thread", "Flagged", "Attachment", "Subject", "From", "Unread", "Date", "Priority", "Size" ); - SOGoSentFolderName = "Sent"; SOGoDraftsFolderName = "Drafts"; SOGoTrashFolderName = "Trash"; diff --git a/SoObjects/SOGo/SOGoSession.m b/SoObjects/SOGo/SOGoSession.m index 97a2c8117..d795e6e1c 100644 --- a/SoObjects/SOGo/SOGoSession.m +++ b/SoObjects/SOGo/SOGoSession.m @@ -251,21 +251,23 @@ r = [decodedValue rangeOfString: @":"]; *theLogin = [decodedValue substringToIndex: r.location]; *thePassword = [decodedValue substringFromIndex: r.location+1]; - - r = [*theLogin rangeOfString: @"@" options: NSBackwardsSearch]; - if (r.location != NSNotFound) + *theDomain = nil; + + sd = [SOGoSystemDefaults sharedSystemDefaults]; + if ([sd addDomainToUID]) { - // The domain is probably appended to the username; - // make sure it is defined as a login domain in the configuration. - sd = [SOGoSystemDefaults sharedSystemDefaults]; - *theDomain = [*theLogin substringFromIndex: (r.location + r.length)]; - if ([[sd loginDomains] containsObject: *theDomain]) - *theLogin = [*theLogin substringToIndex: r.location]; - else - *theDomain = nil; + r = [*theLogin rangeOfString: @"@" options: NSBackwardsSearch]; + if (r.location != NSNotFound) + { + // 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]) + *theLogin = [*theLogin substringToIndex: r.location]; + else + *theDomain = nil; + } } - else - *theDomain = nil; } @end diff --git a/SoObjects/SOGo/SOGoSystemDefaults.h b/SoObjects/SOGo/SOGoSystemDefaults.h index 09e5cce65..ae241774e 100644 --- a/SoObjects/SOGo/SOGoSystemDefaults.h +++ b/SoObjects/SOGo/SOGoSystemDefaults.h @@ -34,6 +34,7 @@ + (SOGoSystemDefaults *) sharedSystemDefaults; - (NSArray *) domainIds; +- (BOOL) addDomainToUID; - (NSArray *) loginDomains; - (NSArray *) visibleDomainsForDomain: (NSString *) domain; diff --git a/SoObjects/SOGo/SOGoSystemDefaults.m b/SoObjects/SOGo/SOGoSystemDefaults.m index 72aaa3556..f67fb3a19 100644 --- a/SoObjects/SOGo/SOGoSystemDefaults.m +++ b/SoObjects/SOGo/SOGoSystemDefaults.m @@ -193,6 +193,11 @@ BootstrapNSUserDefaults () return [[self dictionaryForKey: @"domains"] allKeys]; } +- (BOOL) addDomainToUID +{ + return ([[self domainIds] count] > 0 && [self boolForKey: @"SOGoAddDomainToUID"]); +} + - (NSArray *) loginDomains { NSMutableArray *filteredLoginDomains; @@ -237,11 +242,11 @@ BootstrapNSUserDefaults () [domains addObjectsFromArray: currentGroup]; } - // Remove lookup domain from list + // Remove lookup domain and invalid domains groups = [domains objectEnumerator]; while ((currentDomain = [groups nextObject])) { - if ([currentDomain isEqualToString: domain]) + if ([currentDomain isEqualToString: domain] || ![definedDomains containsObject: currentDomain]) [domains removeObject: currentDomain]; } diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index 42de92e95..e68089bd1 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -124,7 +124,8 @@ /** * Return a new instance for the login name, which can be appended by a - * domain name. + * domain name. The domain is extracted only if the system defaults + * SOGoAddDomainToUID is enabled. * * @param newLogin a login name optionally follow by @domain * @param newRoles @@ -152,17 +153,20 @@ realUID = newLogin; else { - r = [newLogin rangeOfString: @"@" options: NSBackwardsSearch]; - if (r.location != NSNotFound) + sd = [SOGoSystemDefaults sharedSystemDefaults]; + if ([sd addDomainToUID]) { - // The domain is probably appended to the username; - // make sure it is defined as a login domain in the configuration. - sd = [SOGoSystemDefaults sharedSystemDefaults]; - domain = [newLogin substringFromIndex: (r.location + r.length)]; - if ([[sd loginDomains] containsObject: domain]) - newLogin = [newLogin substringToIndex: r.location]; - else - domain = nil; + r = [newLogin rangeOfString: @"@" options: NSBackwardsSearch]; + if (r.location != NSNotFound) + { + // 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]) + newLogin = [newLogin substringToIndex: r.location]; + else + domain = nil; + } } newLogin = [newLogin stringByReplacingString: @"%40" diff --git a/SoObjects/SOGo/SOGoUserManager.h b/SoObjects/SOGo/SOGoUserManager.h index c24d25515..ef5ca18cd 100644 --- a/SoObjects/SOGo/SOGoUserManager.h +++ b/SoObjects/SOGo/SOGoUserManager.h @@ -83,7 +83,7 @@ - (BOOL) checkLogin: (NSString *) _login password: (NSString *) _pwd - domain: (NSString *) _domain + domain: (NSString **) _domain perr: (SOGoPasswordPolicyError *) _perr expire: (int *) _expire grace: (int *) _grace; diff --git a/SoObjects/SOGo/SOGoUserManager.m b/SoObjects/SOGo/SOGoUserManager.m index 6788927dd..e67389444 100644 --- a/SoObjects/SOGo/SOGoUserManager.m +++ b/SoObjects/SOGo/SOGoUserManager.m @@ -396,7 +396,7 @@ - (BOOL) _sourceCheckLogin: (NSString *) login andPassword: (NSString *) password - domain: (NSString *) domain + domain: (NSString **) domain perr: (SOGoPasswordPolicyError *) perr expire: (int *) expire grace: (int *) grace @@ -408,23 +408,26 @@ checkOK = NO; - authIDs = [[self authenticationSourceIDsInDomain: domain] objectEnumerator]; + authIDs = [[self authenticationSourceIDsInDomain: *domain] objectEnumerator]; while (!checkOK && (currentID = [authIDs nextObject])) { sogoSource = [_sources objectForKey: currentID]; checkOK = [sogoSource checkLogin: login - password: password - perr: perr - expire: expire - grace: grace]; + password: password + perr: perr + expire: expire + grace: grace]; } + if (checkOK && *domain == nil) + *domain = [sogoSource domain]; + return checkOK; } - (BOOL) checkLogin: (NSString *) _login password: (NSString *) _pwd - domain: (NSString *) _domain + domain: (NSString **) _domain perr: (SOGoPasswordPolicyError *) _perr expire: (int *) _expire grace: (int *) _grace @@ -436,8 +439,8 @@ // We check for cached passwords. If the entry is cached, we // check this immediately. If not, we'll go directly at the // authentication source and try to validate there, then cache it. - if (_domain) - username = [NSString stringWithFormat: @"%@@%@", _login, _domain]; + if (*_domain != nil) + username = [NSString stringWithFormat: @"%@@%@", _login, *_domain]; else username = _login; jsonUser = [[SOGoCache sharedCache] userAttributesForLogin: username]; @@ -502,13 +505,12 @@ newPassword: (NSString *) newPassword perr: (SOGoPasswordPolicyError *) perr { - NSString *dictPassword, *jsonUser; + NSString *jsonUser; NSMutableDictionary *currentUser; BOOL didChange; jsonUser = [[SOGoCache sharedCache] userAttributesForLogin: login]; currentUser = [jsonUser objectFromJSONString]; - dictPassword = [currentUser objectForKey: @"password"]; if ([self _sourceChangePasswordForLogin: login inDomain: domain @@ -713,27 +715,31 @@ domain = nil; infos = nil; - r = [uid rangeOfString: @"@" options: NSBackwardsSearch]; - if (r.location != NSNotFound) + sd = [SOGoSystemDefaults sharedSystemDefaults]; + if ([sd addDomainToUID]) { - // The domain is probably appended to the username; - // make sure it is a defined domain in the configuration. - sd = [SOGoSystemDefaults sharedSystemDefaults]; - domain = [uid substringFromIndex: (r.location + r.length)]; - if ([[sd domainIds] containsObject: domain]) - username = [uid substringToIndex: r.location]; - else - domain = nil; + r = [uid rangeOfString: @"@" options: NSBackwardsSearch]; + if (r.location != NSNotFound) + { + // 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]) + username = [uid substringToIndex: r.location]; + else + domain = nil; + } + if (domain != nil) + infos = [self contactInfosForUserWithUIDorEmail: username + inDomain: domain]; } - if (domain != nil) - infos = [self contactInfosForUserWithUIDorEmail: username - inDomain: domain]; + if (infos == nil) // If the user was not found using the domain or if no domain was detected, // search using the original uid. infos = [self contactInfosForUserWithUIDorEmail: uid inDomain: nil]; - + return infos; } diff --git a/SoObjects/SOGo/SOGoWebAuthenticator.h b/SoObjects/SOGo/SOGoWebAuthenticator.h index c47b626de..870a4c416 100644 --- a/SoObjects/SOGo/SOGoWebAuthenticator.h +++ b/SoObjects/SOGo/SOGoWebAuthenticator.h @@ -40,7 +40,7 @@ - (BOOL) checkLogin: (NSString *) _login password: (NSString *) _pwd - domain: (NSString *) _domain + domain: (NSString **) _domain perr: (SOGoPasswordPolicyError *) _perr expire: (int *) _expire grace: (int *) _grace; diff --git a/SoObjects/SOGo/SOGoWebAuthenticator.m b/SoObjects/SOGo/SOGoWebAuthenticator.m index 0cb65c47b..ac35d31e2 100644 --- a/SoObjects/SOGo/SOGoWebAuthenticator.m +++ b/SoObjects/SOGo/SOGoWebAuthenticator.m @@ -65,7 +65,7 @@ - (BOOL) checkLogin: (NSString *) _login password: (NSString *) _pwd { - NSString *username, *domain, *password, *value; + NSString *username, *password, *domain, *value; SOGoPasswordPolicyError perr; int expire, grace; @@ -83,6 +83,7 @@ if (!value) return NO; + domain = nil; [SOGoSession decodeValue: value usingKey: _login login: &username @@ -91,7 +92,7 @@ return [self checkLogin: username password: password - domain: domain + domain: &domain perr: &perr expire: &expire grace: &grace]; @@ -99,7 +100,7 @@ - (BOOL) checkLogin: (NSString *) _login password: (NSString *) _pwd - domain: (NSString *) _domain + domain: (NSString **) _domain perr: (SOGoPasswordPolicyError *) _perr expire: (int *) _expire grace: (int *) _grace @@ -207,7 +208,7 @@ if (![self checkLogin: login password: pwd - domain: domain + domain: &domain perr: &perr expire: &expire grace: &grace]) diff --git a/UI/MainUI/SOGoRootPage.m b/UI/MainUI/SOGoRootPage.m index 7fd46cbfd..765efe587 100644 --- a/UI/MainUI/SOGoRootPage.m +++ b/UI/MainUI/SOGoRootPage.m @@ -167,7 +167,7 @@ language = [request formValueForKey: @"language"]; domain = [request formValueForKey: @"domain"]; - if ((b = [auth checkLogin: username password: password domain: domain + if ((b = [auth checkLogin: username password: password domain: &domain perr: &err expire: &expire grace: &grace]) && (err == PolicyNoError) // no password policy diff --git a/UI/MainUI/SOGoUserHomePage.m b/UI/MainUI/SOGoUserHomePage.m index bf2908684..c7cc41906 100644 --- a/UI/MainUI/SOGoUserHomePage.m +++ b/UI/MainUI/SOGoUserHomePage.m @@ -366,30 +366,31 @@ { NSMutableArray *users; NSArray *currentUsers; - NSString *contact, *domain; + NSString *contact, *domain, *uidDomain; NSEnumerator *visibleDomains; id result; SOGoUserManager *um; SOGoSystemDefaults *sd; - um = [SOGoUserManager sharedUserManager]; contact = [self queryParameterForKey: @"search"]; if ([contact length]) { + um = [SOGoUserManager sharedUserManager]; + sd = [SOGoSystemDefaults sharedSystemDefaults]; domain = [[context activeUser] domain]; + uidDomain = [sd addDomainToUID]? domain : nil; users = [self _usersForResults: [um fetchUsersMatching: contact inDomain: domain] - inDomain: domain]; + inDomain: uidDomain]; if ([domain length]) { // Add results from visible domains - sd = [SOGoSystemDefaults sharedSystemDefaults]; visibleDomains = [[sd visibleDomainsForDomain: domain] objectEnumerator]; while ((domain = [visibleDomains nextObject])) { currentUsers = [self _usersForResults: [um fetchUsersMatching: contact inDomain: domain] - inDomain: domain]; + inDomain: uidDomain]; [users addObjectsFromArray: currentUsers]; } }