Fix for bug #1061.

pull/7/head
Ludovic Marcotte 2012-11-26 13:13:06 -05:00
parent 6d61e064a5
commit 7c250fad8f
7 changed files with 47 additions and 4 deletions

View File

@ -62,8 +62,11 @@
NSString *IDField; // the first part of a user DN NSString *IDField; // the first part of a user DN
NSString *CNField; NSString *CNField;
NSString *UIDField; NSString *UIDField;
NSArray *mailFields, *searchFields; NSArray *mailFields;
NSString *IMAPHostField, *IMAPLoginField; NSArray *searchFields;
NSString *IMAPHostField;
NSString *IMAPLoginField;
NSString *SieveHostField;
NSArray *bindFields; NSArray *bindFields;
BOOL listRequiresDot; BOOL listRequiresDot;
@ -110,6 +113,7 @@
searchFields: (NSArray *) newSearchFields searchFields: (NSArray *) newSearchFields
IMAPHostField: (NSString *) newIMAPHostField IMAPHostField: (NSString *) newIMAPHostField
IMAPLoginField: (NSString *) newIMAPLoginField IMAPLoginField: (NSString *) newIMAPLoginField
SieveHostField: (NSString *) newSieveHostField
bindFields: (id) newBindFields bindFields: (id) newBindFields
kindField: (NSString *) newKindField kindField: (NSString *) newKindField
andMultipleBookingsField: (NSString *) newMultipleBookingsField; andMultipleBookingsField: (NSString *) newMultipleBookingsField;

View File

@ -107,6 +107,7 @@ static Class NSStringK;
[searchFields retain]; [searchFields retain];
IMAPHostField = nil; IMAPHostField = nil;
IMAPLoginField = nil; IMAPLoginField = nil;
SieveHostField = nil;
bindFields = nil; bindFields = nil;
_scope = @"sub"; _scope = @"sub";
_filter = nil; _filter = nil;
@ -149,6 +150,7 @@ static Class NSStringK;
[searchFields release]; [searchFields release];
[IMAPHostField release]; [IMAPHostField release];
[IMAPLoginField release]; [IMAPLoginField release];
[SieveHostField release];
[bindFields release]; [bindFields release];
[_filter release]; [_filter release];
[_userPasswordAlgorithm release]; [_userPasswordAlgorithm release];
@ -194,6 +196,7 @@ static Class NSStringK;
searchFields: [udSource objectForKey: @"SearchFieldNames"] searchFields: [udSource objectForKey: @"SearchFieldNames"]
IMAPHostField: [udSource objectForKey: @"IMAPHostFieldName"] IMAPHostField: [udSource objectForKey: @"IMAPHostFieldName"]
IMAPLoginField: [udSource objectForKey: @"IMAPLoginFieldName"] IMAPLoginField: [udSource objectForKey: @"IMAPLoginFieldName"]
SieveHostField: [udSource objectForKey: @"SieveHostFieldName"]
bindFields: [udSource objectForKey: @"bindFields"] bindFields: [udSource objectForKey: @"bindFields"]
kindField: [udSource objectForKey: @"KindFieldName"] kindField: [udSource objectForKey: @"KindFieldName"]
andMultipleBookingsField: [udSource objectForKey: @"MultipleBookingsFieldName"]]; andMultipleBookingsField: [udSource objectForKey: @"MultipleBookingsFieldName"]];
@ -311,6 +314,7 @@ static Class NSStringK;
searchFields: (NSArray *) newSearchFields searchFields: (NSArray *) newSearchFields
IMAPHostField: (NSString *) newIMAPHostField IMAPHostField: (NSString *) newIMAPHostField
IMAPLoginField: (NSString *) newIMAPLoginField IMAPLoginField: (NSString *) newIMAPLoginField
SieveHostField: (NSString *) newSieveHostField
bindFields: (id) newBindFields bindFields: (id) newBindFields
kindField: (NSString *) newKindField kindField: (NSString *) newKindField
andMultipleBookingsField: (NSString *) newMultipleBookingsField andMultipleBookingsField: (NSString *) newMultipleBookingsField
@ -326,6 +330,8 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField
ASSIGN(IMAPHostField, [newIMAPHostField lowercaseString]); ASSIGN(IMAPHostField, [newIMAPHostField lowercaseString]);
if (newIMAPLoginField) if (newIMAPLoginField)
ASSIGN(IMAPLoginField, [newIMAPLoginField lowercaseString]); ASSIGN(IMAPLoginField, [newIMAPLoginField lowercaseString]);
if (newSieveHostField)
ASSIGN(SieveHostField, [newSieveHostField lowercaseString]);
if (newMailFields) if (newMailFields)
ASSIGN(mailFields, newMailFields); ASSIGN(mailFields, newMailFields);
if (newSearchFields) if (newSearchFields)
@ -848,6 +854,13 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField
if ([ldapValue length] > 0) if ([ldapValue length] > 0)
[ldifRecord setObject: ldapValue forKey: @"c_imaplogin"]; [ldifRecord setObject: ldapValue forKey: @"c_imaplogin"];
} }
if (SieveHostField)
{
ldapValue = [[ldapEntry attributeWithName: SieveHostField] stringValueAtIndex: 0];
if ([ldapValue length] > 0)
[ldifRecord setObject: ldapValue forKey: @"c_sievehostname"];
}
} }
- (void) _fillConstraints: (NGLdapEntry *) ldapEntry - (void) _fillConstraints: (NGLdapEntry *) ldapEntry
@ -1609,6 +1622,7 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection,
searchFields: nil searchFields: nil
IMAPHostField: nil IMAPHostField: nil
IMAPLoginField: nil IMAPLoginField: nil
SieveHostField: nil
bindFields: nil bindFields: nil
kindField: nil kindField: nil
andMultipleBookingsField: nil]; andMultipleBookingsField: nil];

View File

@ -736,7 +736,12 @@ static NSString *sieveScriptName = @"sogo";
// //
// Values such as "localhost" or "localhost:2000" are NOT supported. // Values such as "localhost" or "localhost:2000" are NOT supported.
// //
sieveServer = [dd sieveServer]; // We first try to get the user's preferred Sieve server
sieveServer = [[[user mailAccounts] objectAtIndex: 0] objectForKey: @"sieveServerName"];
if (!sieveServer)
sieveServer = [dd sieveServer];
sievePort = 2000; sievePort = 2000;
url = nil; url = nil;

View File

@ -577,7 +577,7 @@
- (void) _appendSystemMailAccount - (void) _appendSystemMailAccount
{ {
NSString *fullName, *replyTo, *imapLogin, *imapServer, *signature, NSString *fullName, *replyTo, *imapLogin, *imapServer, *signature,
*encryption, *scheme, *action, *query, *customEmail; *encryption, *scheme, *action, *query, *customEmail, *sieveServer;
NSMutableDictionary *mailAccount, *identity, *mailboxes, *receipts; NSMutableDictionary *mailAccount, *identity, *mailboxes, *receipts;
NSNumber *port; NSNumber *port;
NSMutableArray *identities; NSMutableArray *identities;
@ -637,6 +637,15 @@
[mailAccount setObject: port forKey: @"port"]; [mailAccount setObject: port forKey: @"port"];
[mailAccount setObject: encryption forKey: @"encryption"]; [mailAccount setObject: encryption forKey: @"encryption"];
// Sieve server
sieveServer = [self _fetchFieldForUser: @"c_sievehostname"];
if (sieveServer)
{
[mailAccount setObject: sieveServer forKey: @"sieveServerName"];
}
/* identities */ /* identities */
identities = [NSMutableArray new]; identities = [NSMutableArray new];
mails = [self allEmails]; mails = [self allEmails];

View File

@ -43,6 +43,7 @@
NSArray *_mailFields; NSArray *_mailFields;
NSString *_imapLoginField; NSString *_imapLoginField;
NSString *_imapHostField; NSString *_imapHostField;
NSString *_sieveHostField;
NSString *_userPasswordAlgorithm; NSString *_userPasswordAlgorithm;
NSURL *_viewURL; NSURL *_viewURL;
BOOL _prependPasswordScheme; BOOL _prependPasswordScheme;

View File

@ -98,6 +98,7 @@
_kindField = nil; _kindField = nil;
_multipleBookingsField = nil; _multipleBookingsField = nil;
_imapHostField = nil; _imapHostField = nil;
_sieveHostField = nil;
} }
return self; return self;
@ -115,6 +116,7 @@
[_multipleBookingsField release]; [_multipleBookingsField release];
[_domainField release]; [_domainField release];
[_imapHostField release]; [_imapHostField release];
[_sieveHostField release];
[super dealloc]; [super dealloc];
} }
@ -131,6 +133,7 @@
ASSIGN(_userPasswordAlgorithm, [udSource objectForKey: @"userPasswordAlgorithm"]); ASSIGN(_userPasswordAlgorithm, [udSource objectForKey: @"userPasswordAlgorithm"]);
ASSIGN(_imapLoginField, [udSource objectForKey: @"IMAPLoginFieldName"]); ASSIGN(_imapLoginField, [udSource objectForKey: @"IMAPLoginFieldName"]);
ASSIGN(_imapHostField, [udSource objectForKey: @"IMAPHostFieldName"]); ASSIGN(_imapHostField, [udSource objectForKey: @"IMAPHostFieldName"]);
ASSIGN(_sieveHostField, [udSource objectForKey: @"SieveHostFieldName"]);
ASSIGN(_kindField, [udSource objectForKey: @"KindFieldName"]); ASSIGN(_kindField, [udSource objectForKey: @"KindFieldName"]);
ASSIGN(_multipleBookingsField, [udSource objectForKey: @"MultipleBookingsFieldName"]); ASSIGN(_multipleBookingsField, [udSource objectForKey: @"MultipleBookingsFieldName"]);
ASSIGN(_domainField, [udSource objectForKey: @"DomainFieldName"]); ASSIGN(_domainField, [udSource objectForKey: @"DomainFieldName"]);
@ -524,6 +527,13 @@
[response setObject: value forKey: @"c_imaphostname"]; [response setObject: value forKey: @"c_imaphostname"];
} }
if (_sieveHostField)
{
value = [response objectForKey: _sieveHostField];
if ([value isNotNull])
[response setObject: value forKey: @"c_sievehostname"];
}
// We check if the user can authenticate // We check if the user can authenticate
if (_authenticationFilter) if (_authenticationFilter)
{ {