From 097d5c2333515092f03ace5e64fc6824682ba974 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Tue, 24 Mar 2015 08:40:13 -0400 Subject: [PATCH] now possible to configure objectClass names for LDAP groups using GroupObjectClasses (#1499) --- Documentation/SOGoInstallationGuide.asciidoc | 5 +++ NEWS | 1 + SoObjects/SOGo/LDAPSource.h | 2 + SoObjects/SOGo/LDAPSource.m | 40 ++++++++++++++------ SoObjects/SOGo/SOGoGroup.m | 13 ++++--- SoObjects/SOGo/SOGoSource.h | 1 + 6 files changed, 45 insertions(+), 17 deletions(-) diff --git a/Documentation/SOGoInstallationGuide.asciidoc b/Documentation/SOGoInstallationGuide.asciidoc index e128b02c4..e74cf48b0 100644 --- a/Documentation/SOGoInstallationGuide.asciidoc +++ b/Documentation/SOGoInstallationGuide.asciidoc @@ -1048,6 +1048,11 @@ of supported attributes. user addressbooks (see _abOU_ below), this list of object classes will be applied to new records as they are created. +|GroupObjectClasses +|A list (array) of names identifying groups within the LDAP source. If not +set, SOGo will use `group`, `groupofnames`, `groupofuniquenames` +and `posixgroup`. + |modifiers |A list (array) of usernames that are authorized to perform modifications to the address book defined by this LDAP source. diff --git a/NEWS b/NEWS index 176a81059..cd6363480 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,7 @@ Enhancements - immediately delete mails from EAS clients when they are marked as deleted on the IMAP server - now favor login@domain as the default email address if multiple mail: fields are specified - enable by default HTML mails support using EAS on Windows and BB phones + - now possible to configure objectClass names for LDAP groups using GroupObjectClasses (#1499) Bug fixes - fixed login issue after password change (#2601) diff --git a/SoObjects/SOGo/LDAPSource.h b/SoObjects/SOGo/LDAPSource.h index 938948cd2..3877ec4ee 100644 --- a/SoObjects/SOGo/LDAPSource.h +++ b/SoObjects/SOGo/LDAPSource.h @@ -72,6 +72,7 @@ NSDictionary *contactMapping; NSArray *contactObjectClasses; + NSArray *groupObjectClasses; NSDictionary *modulesConstraints; @@ -106,6 +107,7 @@ UIDField: (NSString *) newUIDField mailFields: (NSArray *) newMailFields searchFields: (NSArray *) newSearchFields +groupObjectClasses: (NSArray *) newGroupObjectClasses IMAPHostField: (NSString *) newIMAPHostField IMAPLoginField: (NSString *) newIMAPLoginField SieveHostField: (NSString *) newSieveHostField diff --git a/SoObjects/SOGo/LDAPSource.m b/SoObjects/SOGo/LDAPSource.m index 23f22c1e7..598e56ffe 100644 --- a/SoObjects/SOGo/LDAPSource.m +++ b/SoObjects/SOGo/LDAPSource.m @@ -101,6 +101,8 @@ static Class NSStringK; contactMapping = nil; searchFields = [NSArray arrayWithObjects: @"sn", @"displayname", @"telephonenumber", nil]; [searchFields retain]; + groupObjectClasses = [NSArray arrayWithObjects: @"group", @"groupofnames", @"groupofuniquenames", @"posixgroup", nil]; + [groupObjectClasses retain]; IMAPHostField = nil; IMAPLoginField = nil; SieveHostField = nil; @@ -144,6 +146,7 @@ static Class NSStringK; [contactMapping release]; [mailFields release]; [searchFields release]; + [groupObjectClasses release]; [IMAPHostField release]; [IMAPLoginField release]; [SieveHostField release]; @@ -189,6 +192,7 @@ static Class NSStringK; UIDField: [udSource objectForKey: @"UIDFieldName"] mailFields: [udSource objectForKey: @"MailFieldNames"] searchFields: [udSource objectForKey: @"SearchFieldNames"] + groupObjectClasses: [udSource objectForKey: @"GroupObjectClasses"] IMAPHostField: [udSource objectForKey: @"IMAPHostFieldName"] IMAPLoginField: [udSource objectForKey: @"IMAPLoginFieldName"] SieveHostField: [udSource objectForKey: @"SieveHostFieldName"] @@ -310,6 +314,7 @@ static Class NSStringK; UIDField: (NSString *) newUIDField mailFields: (NSArray *) newMailFields searchFields: (NSArray *) newSearchFields +groupObjectClasses: (NSArray *) newGroupObjectClasses IMAPHostField: (NSString *) newIMAPHostField IMAPLoginField: (NSString *) newIMAPLoginField SieveHostField: (NSString *) newSieveHostField @@ -334,6 +339,8 @@ static Class NSStringK; ASSIGN(mailFields, newMailFields); if (newSearchFields) ASSIGN(searchFields, newSearchFields); + if (newGroupObjectClasses) + ASSIGN(groupObjectClasses, newGroupObjectClasses); if (newBindFields) { // Before SOGo v1.2.0, bindFields was a comma-separated list @@ -1031,6 +1038,8 @@ static Class NSStringK; NSString *value; static NSArray *resourceKinds = nil; NSMutableArray *classes; + NSEnumerator *gclasses; + NSString *gclass; id o; if (!resourceKinds) @@ -1059,24 +1068,27 @@ static Class NSStringK; if (classes) { - // We check if our entry is a group. If so, we set the - // 'isGroup' custom attribute. - if ([classes containsObject: @"group"] || - [classes containsObject: @"groupofnames"] || - [classes containsObject: @"groupofuniquenames"] || - [classes containsObject: @"posixgroup"]) - { - [ldifRecord setObject: [NSNumber numberWithInt: 1] - forKey: @"isGroup"]; - } // We check if our entry is a resource. We also support // determining resources based on the KindFieldName attribute // value - see below. - else if ([classes containsObject: @"calendarresource"]) + if ([classes containsObject: @"calendarresource"]) { [ldifRecord setObject: [NSNumber numberWithInt: 1] forKey: @"isResource"]; } + else + { + // We check if our entry is a group. If so, we set the + // 'isGroup' custom attribute. + gclasses = [groupObjectClasses objectEnumerator]; + while (gclass = [gclasses nextObject]) + if ([classes containsObject: [gclass lowercaseString]]) + { + [ldifRecord setObject: [NSNumber numberWithInt: 1] + forKey: @"isGroup"]; + break; + } + } } // We check if that entry corresponds to a resource. For this, @@ -1368,6 +1380,11 @@ static Class NSStringK; return modifiers; } +- (NSArray *) groupObjectClasses +{ + return groupObjectClasses; +} + static NSArray * _convertRecordToLDAPAttributes (LDAPSourceSchema *schema, NSDictionary *ldifRecord) { @@ -1683,6 +1700,7 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection, UIDField: @"cn" mailFields: nil searchFields: nil + groupObjectClasses: nil IMAPHostField: nil IMAPLoginField: nil SieveHostField: nil diff --git a/SoObjects/SOGo/SOGoGroup.m b/SoObjects/SOGo/SOGoGroup.m index 648b97ae4..cacdd7770 100644 --- a/SoObjects/SOGo/SOGoGroup.m +++ b/SoObjects/SOGo/SOGoGroup.m @@ -137,6 +137,8 @@ NGLdapEntry *entry; NSObject *source; id o; + NSEnumerator *gclasses; + NSString *gclass; int i; @@ -194,12 +196,11 @@ } } - // Found a group, let's return it. - if ([classes containsObject: @"group"] || - [classes containsObject: @"groupofnames"] || - [classes containsObject: @"groupofuniquenames"] || - [classes containsObject: @"posixgroup"]) - { + gclasses = [[source groupObjectClasses] objectEnumerator]; + while (gclass = [gclasses nextObject]) + if ([classes containsObject: gclass]) + { + // Found a group, let's return it. o = [[self alloc] initWithIdentifier: theValue domain: domain source: source diff --git a/SoObjects/SOGo/SOGoSource.h b/SoObjects/SOGo/SOGoSource.h index 2415f408c..b55a5a14a 100644 --- a/SoObjects/SOGo/SOGoSource.h +++ b/SoObjects/SOGo/SOGoSource.h @@ -110,6 +110,7 @@ - (NSString *) baseDN; - (NSString *) MSExchangeHostname; +- (NSArray *) groupObjectClasses; @end #endif /* SOGOSOURCE_H */