View Issue Details

IDProjectCategoryView StatusLast Update
0001499SOGoBackend Generalpublic2015-03-24 08:41
Reporterdab1818 Assigned Toludovic  
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionfixed 
Product Version1.3.9 
Target Version2.2.17Fixed in Version2.2.17 
Summary0001499: LDAP group classes list must be configurable like 'SearchFieldNames'.
Description

now this list hardcoded in SoObjects/SOGo/LDAPSource.m/_convertLDAPEntryToContact.

TagsNo tags attached.

Activities

dab1818

dab1818

2015-03-24 08:14

reporter   ~0008354

groupObjectClasses-2.2.16.patch allow to specify GroupObjectClasses in config:

SOGoUserSources = (
{
id = ldapaddressbook;
type = ldap;
....
GroupObjectClasses = (groupOfUniqueNames,posixGroup);

i'm not sure about modifications in SOGoGroup.m, please correct me :)
and tested only with ldap user source.

dab1818

dab1818

2015-03-24 08:15

reporter  

groupObjectClasses-2.2.16.patch (6,248 bytes)   
--- SOGo-2.2.16/SoObjects/SOGo/LDAPSource.h.orig	2015-02-12 20:13:16.000000000 +0400
+++ SOGo-2.2.16/SoObjects/SOGo/LDAPSource.h	2015-03-24 11:33:21.105809603 +0400
@@ -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
--- SOGo-2.2.16/SoObjects/SOGo/LDAPSource.m.orig	2015-02-12 20:13:16.000000000 +0400
+++ SOGo-2.2.16/SoObjects/SOGo/LDAPSource.m	2015-03-24 11:36:36.603875934 +0400
@@ -101,6 +101,8 @@
       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 @@
   [contactMapping release];
   [mailFields release];
   [searchFields release];
+  [groupObjectClasses release];
   [IMAPHostField release];
   [IMAPLoginField release];
   [SieveHostField release];
@@ -189,6 +192,7 @@
              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 @@
           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 @@
     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 @@
   NSString *value;
   static NSArray *resourceKinds = nil;
   NSMutableArray *classes;
+  NSEnumerator *gclasses;
+  NSString *gclass;
   id o;
 
   if (!resourceKinds)
@@ -1059,24 +1068,27 @@
 
   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 @@
   return modifiers;
 }
 
+- (NSArray *) groupObjectClasses
+{
+  return groupObjectClasses;
+}
+
 static NSArray *
 _convertRecordToLDAPAttributes (LDAPSourceSchema *schema, NSDictionary *ldifRecord)
 {
@@ -1683,6 +1700,7 @@
                                        UIDField: @"cn"
                                      mailFields: nil
                                    searchFields: nil
+                             groupObjectClasses: nil
                                   IMAPHostField: nil
                                  IMAPLoginField: nil
                                  SieveHostField: nil
--- SOGo-2.2.16/SoObjects/SOGo/SOGoGroup.m.orig	2015-02-12 20:13:16.000000000 +0400
+++ SOGo-2.2.16/SoObjects/SOGo/SOGoGroup.m	2015-03-24 12:09:04.217945453 +0400
@@ -137,6 +137,8 @@
   NGLdapEntry *entry;
   NSObject <SOGoSource> *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
--- SOGo-2.2.16/SoObjects/SOGo/SOGoSource.h.orig	2015-02-12 20:13:16.000000000 +0400
+++ SOGo-2.2.16/SoObjects/SOGo/SOGoSource.h	2015-03-24 11:34:22.598534713 +0400
@@ -110,6 +110,7 @@
 - (NSString *) baseDN;
 - (NSString *) MSExchangeHostname;
 
+- (NSArray *) groupObjectClasses;
 @end
 
 #endif /* SOGOSOURCE_H */
ludovic

ludovic

2015-03-24 08:41

administrator   ~0008355

Fix + doc pushed:

https://github.com/inverse-inc/sogo/commit/097d5c2333515092f03ace5e64fc6824682ba974

Thanks for your contribution!

Issue History

Date Modified Username Field Change
2011-11-16 00:28 dab1818 New Issue
2015-03-24 08:14 dab1818 Note Added: 0008354
2015-03-24 08:15 dab1818 File Added: groupObjectClasses-2.2.16.patch
2015-03-24 08:40 ludovic Target Version => 2.2.17
2015-03-24 08:41 ludovic Note Added: 0008355
2015-03-24 08:41 ludovic Status new => resolved
2015-03-24 08:41 ludovic Fixed in Version => 2.2.17
2015-03-24 08:41 ludovic Resolution open => fixed
2015-03-24 08:41 ludovic Assigned To => ludovic