Monotone-Parent: e38c570559610854b85c2c517053417779a76964

Monotone-Revision: 419d3afdcfcc1cddf8eef1f0311d418b03b0d1a0

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2011-11-17T16:15:38
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2011-11-17 16:15:38 +00:00
parent 53e125bd7a
commit 6f13029d21
8 changed files with 76 additions and 34 deletions

View File

@ -1,3 +1,10 @@
2011-11-17 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* OpenChange/MAPIStoreMessage.m (MAPIStoreInternalEntryId): now
takes a ldb_context * parameter pointing to the samdb, which
enables us: 1) to return the real legacyExchangeDN 2) to make use
of sAMAccountName as search parameter for the username.
2011-11-16 Ludovic Marcotte <lmarcotte@inverse.ca>
* SoObjects/SOGo/SOGoSieveManager.m (-updateFiltersForLogin:...)

View File

@ -39,6 +39,7 @@ extern NSTimeZone *utcTZ;
@interface MAPIStoreAppointmentWrapper : NSObject
{
struct mapistore_connection_info *connInfo;
iCalCalendar *calendar;
iCalEvent *event;
NSTimeZone *timeZone;
@ -56,11 +57,13 @@ extern NSTimeZone *utcTZ;
+ (id) wrapperWithICalEvent: (iCalEvent *) newEvent
andUser: (SOGoUser *) newUser
andSenderEmail: (NSString *) newSenderEmail
inTimeZone: (NSTimeZone *) newTimeZone;
inTimeZone: (NSTimeZone *) newTimeZone
withConnectionInfo: (struct mapistore_connection_info *) newConnInfo;
- (id) initWithICalEvent: (iCalEvent *) newEvent
andUser: (SOGoUser *) newUser
andSenderEmail: (NSString *) newSenderEmail
inTimeZone: (NSTimeZone *) newTimeZone;
inTimeZone: (NSTimeZone *) newTimeZone
withConnectionInfo: (struct mapistore_connection_info *) newConnInfo;
/* getters */
- (void) fillMessageData: (struct mapistore_message *) dataPtr

View File

@ -80,13 +80,15 @@ static NSCharacterSet *hexCharacterSet = nil;
andUser: (SOGoUser *) newUser
andSenderEmail: (NSString *) newSenderEmail
inTimeZone: (NSTimeZone *) newTimeZone
withConnectionInfo: (struct mapistore_connection_info *) newConnInfo
{
MAPIStoreAppointmentWrapper *wrapper;
wrapper = [[self alloc] initWithICalEvent: newEvent
andUser: newUser
andSenderEmail: newSenderEmail
inTimeZone: newTimeZone];
inTimeZone: newTimeZone
withConnectionInfo: newConnInfo];
[wrapper autorelease];
return wrapper;
@ -96,6 +98,7 @@ static NSCharacterSet *hexCharacterSet = nil;
{
if ((self = [super init]))
{
connInfo = NULL;
calendar = nil;
event = nil;
timeZone = nil;
@ -178,9 +181,11 @@ static NSCharacterSet *hexCharacterSet = nil;
andUser: (SOGoUser *) newUser
andSenderEmail: (NSString *) newSenderEmail
inTimeZone: (NSTimeZone *) newTimeZone
withConnectionInfo: (struct mapistore_connection_info *) newConnInfo
{
if ((self = [self init]))
{
connInfo = newConnInfo;
ASSIGN (event, newEvent);
ASSIGN (calendar, [event parent]);
ASSIGN (timeZone, newTimeZone);
@ -256,7 +261,7 @@ static NSCharacterSet *hexCharacterSet = nil;
{
username = [contactInfos objectForKey: @"c_uid"];
recipient->username = [username asUnicodeInMemCtx: msgData];
entryId = MAPIStoreInternalEntryId (username);
entryId = MAPIStoreInternalEntryId (connInfo->sam_ctx, username);
}
else
{
@ -357,7 +362,7 @@ static NSCharacterSet *hexCharacterSet = nil;
{
username = [contactInfos objectForKey: @"c_uid"];
recipient->username = [username asUnicodeInMemCtx: msgData];
entryId = MAPIStoreInternalEntryId (username);
entryId = MAPIStoreInternalEntryId (connInfo->sam_ctx, username);
}
else
{
@ -727,7 +732,7 @@ static NSCharacterSet *hexCharacterSet = nil;
if (contactInfos)
{
username = [contactInfos objectForKey: @"c_uid"];
entryId = MAPIStoreInternalEntryId (username);
entryId = MAPIStoreInternalEntryId (connInfo->sam_ctx, username);
}
else
entryId = MAPIStoreExternalEntryId (cn, email);

View File

@ -104,15 +104,18 @@
- (MAPIStoreAppointmentWrapper *) appointmentWrapper
{
iCalEvent *event;
MAPIStoreContext *context;
if (!appointmentWrapper)
{
event = [sogoObject component: NO secure: NO];
context = [self context];
ASSIGN (appointmentWrapper,
[MAPIStoreAppointmentWrapper wrapperWithICalEvent: event
andUser: [[self context] activeUser]
andUser: [context activeUser]
andSenderEmail: nil
inTimeZone: [self ownerTimeZone]]);
inTimeZone: [self ownerTimeZone]
withConnectionInfo: [context connectionInfo]]);
}
return appointmentWrapper;

View File

@ -263,6 +263,7 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data)
iCalCalendar *calendar;
iCalEvent *event;
NSString *stringValue, *senderEmail;
MAPIStoreContext *context;
if (!appointmentWrapper)
{
@ -280,11 +281,13 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data)
senderEmail = [[from objectAtIndex: 0] email];
else
senderEmail = nil;
context = [self context];
appointmentWrapper = [MAPIStoreAppointmentWrapper
wrapperWithICalEvent: event
andUser: [[self context] activeUser]
andUser: [context activeUser]
andSenderEmail: senderEmail
inTimeZone: [self ownerTimeZone]];
inTimeZone: [self ownerTimeZone]
withConnectionInfo: [context connectionInfo]];
[appointmentWrapper retain];
}
}
@ -721,6 +724,7 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data)
NSDictionary *contactInfos;
NGMailAddress *ngAddress;
NSData *entryId;
struct ldb_context *samCtx;
int rc;
if (fullMail)
@ -743,7 +747,8 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data)
if (contactInfos)
{
username = [contactInfos objectForKey: @"c_uid"];
entryId = MAPIStoreInternalEntryId (username);
samCtx = [[self context] connectionInfo]->sam_ctx;
entryId = MAPIStoreInternalEntryId (samCtx, username);
}
else
entryId = MAPIStoreExternalEntryId (cn, email);
@ -1349,9 +1354,11 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data)
NSData *entryId;
NSDictionary *contactInfos;
SOGoUserManager *mgr;
struct ldb_context *samCtx;
struct mapistore_message *msgData;
struct mapistore_message_recipient *recipient;
samCtx = [[self context] connectionInfo]->sam_ctx;
[super getMessageData: &msgData inMemCtx: memCtx];
if (!headerSetup)
@ -1397,7 +1404,7 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data)
{
username = [contactInfos objectForKey: @"c_uid"];
recipient->username = [username asUnicodeInMemCtx: msgData];
entryId = MAPIStoreInternalEntryId (username);
entryId = MAPIStoreInternalEntryId (samCtx, username);
}
else
{

View File

@ -249,10 +249,13 @@ static NSString *recTypes[] = { @"orig", @"to", @"cc", @"bcc" };
NSData *entryId;
NSDictionary *allRecipients, *dict, *contactInfos;
SOGoUserManager *mgr;
struct ldb_context *samCtx;
struct mapistore_message *msgData;
struct mapistore_message_recipient *recipient;
enum ulRecipClass type;
samCtx = [[self context] connectionInfo]->sam_ctx;
[super getMessageData: &msgData inMemCtx: memCtx];
allRecipients = [[sogoObject properties] objectForKey: @"recipients"];
@ -295,7 +298,7 @@ static NSString *recTypes[] = { @"orig", @"to", @"cc", @"bcc" };
{
username = [contactInfos objectForKey: @"c_uid"];
recipient->username = [username asUnicodeInMemCtx: msgData];
entryId = MAPIStoreInternalEntryId (username);
entryId = MAPIStoreInternalEntryId (samCtx, username);
}
else
{

View File

@ -35,9 +35,11 @@
@class MAPIStoreAttachmentTable;
@class MAPIStoreFolder;
struct ldb_context;
#import "MAPIStoreObject.h"
extern NSData *MAPIStoreInternalEntryId (NSString *username);
extern NSData *MAPIStoreInternalEntryId (struct ldb_context *, NSString *username);
extern NSData *MAPIStoreExternalEntryId (NSString *cn, NSString *email);
@interface MAPIStoreMessage : MAPIStoreObject

View File

@ -55,14 +55,18 @@
static NSString *resourcesDir = nil;
NSData *
MAPIStoreInternalEntryId (NSString *username)
MAPIStoreInternalEntryId (struct ldb_context *samCtx, NSString *username)
{
NSMutableData *entryId;
static uint8_t providerUid[] = { 0xdc, 0xa7, 0x40, 0xc8,
0xc0, 0x42, 0x10, 0x1a,
0xb4, 0xb9, 0x08, 0x00,
0x2b, 0x2f, 0xe1, 0x82 };
NSString *x500dn;
NSMutableData *entryId = nil;
TALLOC_CTX *memCtx;
struct ldb_result *res = NULL;
const char * const attrs[] = { "legacyExchangeDN", NULL };
const char *legacyDn;
int ret;
static const uint8_t const providerUid[] = { 0xdc, 0xa7, 0x40, 0xc8,
0xc0, 0x42, 0x10, 0x1a,
0xb4, 0xb9, 0x08, 0x00,
0x2b, 0x2f, 0xe1, 0x82 };
/* structure:
flags: 32
@ -71,20 +75,28 @@ MAPIStoreInternalEntryId (NSString *username)
type: 32
X500DN: variable */
entryId = [NSMutableData dataWithCapacity: 256];
[entryId appendUInt32: 0]; // flags
[entryId appendBytes: providerUid length: 16]; // provideruid
[entryId appendUInt32: 1]; // version
[entryId appendUInt32: 0]; // type (local mail user)
memCtx = talloc_zero(NULL, TALLOC_CTX);
/* X500DN */
/* FIXME: the DN will likely work on DEMO installations for now but we
really should get the dn prefix from the server */
x500dn = [NSString stringWithFormat: @"/O=FIRST ORGANIZATION"
@"/OU=FIRST ADMINISTRATIVE GROUP"
@"/CN=RECIPIENTS/CN=%@", username];
[entryId appendData: [x500dn dataUsingEncoding: NSISOLatin1StringEncoding]];
[entryId appendUInt8: 0];
/* Search mapistoreURI given partial URI */
ret = ldb_search (samCtx, memCtx, &res, ldb_get_default_basedn(samCtx),
LDB_SCOPE_SUBTREE, attrs,
"(&(objectClass=user)(sAMAccountName=%s))",
[username UTF8String]);
if (ret == LDB_SUCCESS && res->count == 1)
{
legacyDn = ldb_msg_find_attr_as_string (res->msgs[0], attrs[0], NULL);
if (legacyDn)
{
entryId = [NSMutableData dataWithCapacity: 256];
[entryId appendUInt32: 0]; // flags
[entryId appendBytes: providerUid length: 16]; // provideruid
[entryId appendUInt32: 1]; // version
[entryId appendUInt32: 0]; // type (local mail user)
[entryId appendBytes: legacyDn length: strlen (legacyDn) + 1]; // x500dn
}
}
talloc_free(memCtx);
return entryId;
}