From 7d49674d9d431dc6fbb838416f8862af74a95d96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Garc=C3=ADa=20S=C3=A1ez?= Date: Wed, 23 Sep 2015 15:09:45 +0200 Subject: [PATCH] Add domain to lookupContactEntry --- SoObjects/Contacts/SOGoContactSourceFolder.m | 21 ++++++++++++-------- SoObjects/SOGo/LDAPSource.m | 1 + SoObjects/SOGo/SOGoSource.h | 3 ++- SoObjects/SOGo/SOGoUserManager.m | 2 +- SoObjects/SOGo/SQLSource.m | 3 ++- Tools/SOGoToolBackup.m | 14 +++++++------ 6 files changed, 27 insertions(+), 17 deletions(-) diff --git a/SoObjects/Contacts/SOGoContactSourceFolder.m b/SoObjects/Contacts/SOGoContactSourceFolder.m index e385d9c09..26c965d9c 100644 --- a/SoObjects/Contacts/SOGoContactSourceFolder.m +++ b/SoObjects/Contacts/SOGoContactSourceFolder.m @@ -164,9 +164,10 @@ ldifEntry = [childRecords objectForKey: objectName]; if (!ldifEntry) { - ldifEntry = [source lookupContactEntry: objectName]; - if (ldifEntry) - [childRecords setObject: ldifEntry forKey: objectName]; + ldifEntry = [source lookupContactEntry: objectName + inDomain: [[context activeUser] domain]]; + if (ldifEntry) + [childRecords setObject: ldifEntry forKey: objectName]; else if ([self isValidContentName: objectName]) { url = [[[lookupContext request] uri] urlWithoutParameters]; @@ -324,10 +325,14 @@ NSDictionary *record; if (aName && [aName length] > 0) - record = [self _flattenedRecord: [source lookupContactEntry: aName]]; + { + record = [source lookupContactEntry: aName + inDomain: [[context activeUser] domain]]; + record = [self _flattenedRecord: record]; + } else record = nil; - + return record; } @@ -562,7 +567,7 @@ toResponse: (WOResponse *) response { NSObject *element; - NSString *url, *baseURL, *cname; + NSString *url, *baseURL, *cname, *domain; NSString **propertiesArray; NSMutableString *buffer; NSDictionary *object; @@ -579,13 +584,13 @@ max = [refs length]; buffer = [NSMutableString stringWithCapacity: max*512]; - + domain = [[context activeUser] domain]; for (count = 0; count < max; count++) { element = [refs objectAtIndex: count]; url = [[[element firstChild] nodeValue] stringByUnescapingURL]; cname = [self _deduceObjectNameFromURL: url fromBaseURL: baseURL]; - object = [source lookupContactEntry: cname]; + object = [source lookupContactEntry: cname inDomain: domain]; if (object) [self appendObject: object properties: propertiesArray diff --git a/SoObjects/SOGo/LDAPSource.m b/SoObjects/SOGo/LDAPSource.m index f13541024..2973c65a4 100644 --- a/SoObjects/SOGo/LDAPSource.m +++ b/SoObjects/SOGo/LDAPSource.m @@ -1242,6 +1242,7 @@ groupObjectClasses: (NSArray *) newGroupObjectClasses } - (NSDictionary *) lookupContactEntry: (NSString *) theID + inDomain: (NSString *) domain { NGLdapEntry *ldapEntry; EOQualifier *qualifier; diff --git a/SoObjects/SOGo/SOGoSource.h b/SoObjects/SOGo/SOGoSource.h index b55a5a14a..d59a81086 100644 --- a/SoObjects/SOGo/SOGoSource.h +++ b/SoObjects/SOGo/SOGoSource.h @@ -56,7 +56,8 @@ newPassword: (NSString *) newPassword perr: (SOGoPasswordPolicyError *) perr; -- (NSDictionary *) lookupContactEntry: (NSString *) theID; +- (NSDictionary *) lookupContactEntry: (NSString *) theID + inDomain: (NSString *) domain; - (NSDictionary *) lookupContactEntryWithUIDorEmail: (NSString *) entryID inDomain: (NSString *) domain; diff --git a/SoObjects/SOGo/SOGoUserManager.m b/SoObjects/SOGo/SOGoUserManager.m index d5a6a94d0..3846da9d8 100644 --- a/SoObjects/SOGo/SOGoUserManager.m +++ b/SoObjects/SOGo/SOGoUserManager.m @@ -1047,7 +1047,7 @@ static Class NSNullK; while ((sourceID = [sources nextObject])) { currentSource = [_sources objectForKey: sourceID]; - contact = [currentSource lookupContactEntry: uid]; + contact = [currentSource lookupContactEntry: uid inDomain: domain]; if (contact) [contacts addObject: contact]; } diff --git a/SoObjects/SOGo/SQLSource.m b/SoObjects/SOGo/SQLSource.m index 7d0de6c07..06d40557a 100644 --- a/SoObjects/SOGo/SQLSource.m +++ b/SoObjects/SOGo/SQLSource.m @@ -618,8 +618,9 @@ - (NSDictionary *) lookupContactEntry: (NSString *) theID + inDomain: (NSString *) domain { - return [self _lookupContactEntry: theID considerEmail: NO inDomain: nil]; + return [self _lookupContactEntry: theID considerEmail: NO inDomain: domain]; } - (NSDictionary *) lookupContactEntryWithUIDorEmail: (NSString *) entryID diff --git a/Tools/SOGoToolBackup.m b/Tools/SOGoToolBackup.m index fb2b4d016..3f2cb27bc 100644 --- a/Tools/SOGoToolBackup.m +++ b/Tools/SOGoToolBackup.m @@ -363,6 +363,7 @@ } - (BOOL) extractUserLDIFRecord: (NSString *) uid + inDomain: (NSString *) domain intoRecord: (NSMutableDictionary *) userRecord { NSEnumerator *ldapSources; @@ -375,11 +376,11 @@ lm = [SOGoUserManager sharedUserManager]; done = NO; - ldapSources = [[lm authenticationSourceIDsInDomain: nil] objectEnumerator]; + ldapSources = [[lm authenticationSourceIDsInDomain: domain] objectEnumerator]; while (!done && (sourceID = [ldapSources nextObject])) { currentSource = [lm sourceWithID: sourceID]; - userEntry = [currentSource lookupContactEntry: uid]; + userEntry = [currentSource lookupContactEntry: uid inDomain: domain]; if (userEntry) { [userRecord setObject: [userEntry ldifRecordAsString] @@ -411,25 +412,26 @@ - (BOOL) exportUser: (NSDictionary *) theUser { - NSString *exportPath, *gcsUID, *ldapUID; + NSString *exportPath, *gcsUID, *ldapUID, *domain; NSMutableDictionary *userRecord; SOGoSystemDefaults *sd; - + sd = [SOGoSystemDefaults sharedSystemDefaults]; userRecord = [NSMutableDictionary dictionary]; ldapUID = [theUser objectForKey: @"c_uid"]; exportPath = [directory stringByAppendingPathComponent: ldapUID]; - + domain = [theUser objectForKey: @"c_domain"]; gcsUID = [theUser objectForKey: @"c_uid"]; if ([sd enableDomainBasedUID] && [gcsUID rangeOfString: @"@"].location == NSNotFound) gcsUID = [NSString stringWithFormat: @"%@@%@", gcsUID, [theUser objectForKey: @"c_domain"]]; - + return ([self extractUserFolders: gcsUID intoRecord: userRecord] && [self extractUserLDIFRecord: ldapUID + inDomain: domain intoRecord: userRecord] && [self extractUserPreferences: gcsUID intoRecord: userRecord]