diff --git a/ChangeLog b/ChangeLog index 518998723..1bdb0ec27 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2008-05-22 Wolfgang Sourdeau + * SoObjects/SOGo/SOGoUser.m ([SOGoUser -mailAccounts]): request + the user login to the imap server from the LDAP user manager. + + * SoObjects/SOGo/LDAPUserManager.m ([LDAPUserManager + -getImapLoginForUID:uid]): new method that returns the user + identifier to use when login to the imap server, in case it's not + the ldap uid. This is configurable through the boolean user + default "SOGoForceIMAPLoginWithEmail". + * SoObjects/Mailer/SOGoDraftObject.m ([SOGoDraftObject -sendMail]): the email passed as parameter to sendmail is now the bare user email. diff --git a/SoObjects/SOGo/LDAPUserManager.h b/SoObjects/SOGo/LDAPUserManager.h index 319f6ca12..3c067940c 100644 --- a/SoObjects/SOGo/LDAPUserManager.h +++ b/SoObjects/SOGo/LDAPUserManager.h @@ -58,6 +58,7 @@ - (NSString *) getCNForUID: (NSString *) uid; - (NSString *) getEmailForUID: (NSString *) uid; - (NSString *) getFullEmailForUID: (NSString *) uid; +- (NSString *) getImapLoginForUID: (NSString *) uid; - (NSString *) getUIDForEmail: (NSString *) email; - (BOOL) checkLogin: (NSString *) login diff --git a/SoObjects/SOGo/LDAPUserManager.m b/SoObjects/SOGo/LDAPUserManager.m index b630c895e..19a0eb8d4 100644 --- a/SoObjects/SOGo/LDAPUserManager.m +++ b/SoObjects/SOGo/LDAPUserManager.m @@ -34,6 +34,7 @@ static NSString *defaultMailDomain = nil; static BOOL defaultMailDomainIsConfigured = NO; +static BOOL forceImapLoginWithEmail = YES; @implementation LDAPUserManager @@ -55,6 +56,8 @@ static BOOL defaultMailDomainIsConfigured = NO; @" value set to 'localhost'"]; defaultMailDomain = @"localhost"; } + if (!forceImapLoginWithEmail) + forceImapLoginWithEmail = [ud boolForKey: @"SOGoForceIMAPLoginWithEmail"]; } + (BOOL) defaultMailDomainIsConfigured @@ -233,6 +236,11 @@ static BOOL defaultMailDomainIsConfigured = NO; [contactInfos objectForKey: @"c_email"]]; } +- (NSString *) getImapLoginForUID: (NSString *) uid +{ + return ((forceImapLoginWithEmail) ? [self getEmailForUID: uid] : uid); +} + - (NSString *) getUIDForEmail: (NSString *) email { NSDictionary *contactInfos; @@ -254,13 +262,10 @@ static BOOL defaultMailDomainIsConfigured = NO; checkOK = NO; authIDs = [[self authenticationSourceIDs] objectEnumerator]; - currentID = [authIDs nextObject]; - while (currentID && !checkOK) + while (!checkOK && (currentID = [authIDs nextObject])) { ldapSource = [sources objectForKey: currentID]; checkOK = [ldapSource checkLogin: login andPassword: password]; - if (!checkOK) - currentID = [authIDs nextObject]; } return checkOK; diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index 1932e9f03..cfefd1dd4 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -454,14 +454,15 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek"; { NSMutableDictionary *mailAccount, *identity; NSMutableArray *identities; - NSString *name, *fullName; + NSString *name, *fullName, *imapLogin; NSArray *mails; unsigned int count, max; + imapLogin = [[LDAPUserManager sharedUserManager] getImapLoginForUID: login]; mailAccount = [NSMutableDictionary dictionary]; name = [NSString stringWithFormat: @"%@@%@", - login, fallbackIMAP4Server]; - [mailAccount setObject: login forKey: @"userName"]; + imapLogin, fallbackIMAP4Server]; + [mailAccount setObject: imapLogin forKey: @"userName"]; [mailAccount setObject: fallbackIMAP4Server forKey: @"serverName"]; [mailAccount setObject: name forKey: @"name"];