From 18ffca1924c8967977da7b3681f744a57bc61168 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Thu, 31 May 2012 12:36:00 +0000 Subject: [PATCH] See ChangeLog Monotone-Parent: d29498142c4a9f1d780373bd5f0d80b17f6e2c33 Monotone-Revision: 747fe8c2134a990c1cdf3b494c2b7776021cb736 Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2012-05-31T12:36:00 --- ChangeLog | 7 +++++ SoObjects/SOGo/LDAPSource.m | 62 ++----------------------------------- SoObjects/SOGo/SOGoGroup.h | 2 +- SoObjects/SOGo/SOGoGroup.m | 34 ++++++++++++++------ 4 files changed, 34 insertions(+), 71 deletions(-) diff --git a/ChangeLog b/ChangeLog index a254d5c1c..776e2f1a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2012-05-31 Ludovic Marcotte + + * SoObjects/SOGo/SOGoGroup.m - we now handle lowercase + all attribute names + * SoObject/SOGo/LDAPSource.m - moved the lowercasing + of attributes to SOPE. + 2012-05-29 Francis Lachapelle * UI/WebServerResources/UIxMailEditor.js (validateEditorInput): diff --git a/SoObjects/SOGo/LDAPSource.m b/SoObjects/SOGo/LDAPSource.m index 3269ca10c..8a066ee9f 100644 --- a/SoObjects/SOGo/LDAPSource.m +++ b/SoObjects/SOGo/LDAPSource.m @@ -52,64 +52,6 @@ static Class NSStringK; stringByReplacingString: @"'" withString: @"\\'"] \ stringByReplacingString: @"%" withString: @"%%"] -@interface NGLdapAttribute (SOGoLDAP) - -- (id) _asArrayOrString; - -@end - -@implementation NGLdapAttribute (SOGoLDAP) - -- (id) _asArrayOrString -{ - id value; - NSArray *arrayValue; - - arrayValue = [self allStringValues]; - if ([arrayValue count] == 1) - value = [arrayValue objectAtIndex: 0]; - else - value = arrayValue; - - return value; -} - -@end - -@interface NGLdapEntry (SOGoLDAP) - -- (NSMutableDictionary *) _asDictionary; - -@end - -@implementation NGLdapEntry (SOGoLDAP) - -- (NSMutableDictionary *) _asDictionary -{ - NSMutableDictionary *ldapRecord; - NSDictionary *ldapAttributes; - NSArray *keys; - NSString *key; - NSUInteger count, max; - id value; - - ldapAttributes = [self attributes]; - keys = [ldapAttributes allKeys]; - max = [keys count]; - - ldapRecord = [NSMutableDictionary dictionaryWithCapacity: max]; - for (count = 0; count < max; count++) - { - key = [keys objectAtIndex: count]; - value = [[ldapAttributes objectForKey: key] _asArrayOrString]; - if (value) - [ldapRecord setObject: value forKey: [key lowercaseString]]; - } - - return ldapRecord; -} - -@end @implementation LDAPSource @@ -1018,7 +960,7 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField resourceKinds = [[NSArray alloc] initWithObjects: @"location", @"thing", @"group", nil]; - ldifRecord = [ldapEntry _asDictionary]; + ldifRecord = [ldapEntry asDictionary]; [ldifRecord setObject: self forKey: @"source"]; [ldifRecord setObject: [ldapEntry dn] forKey: @"dn"]; @@ -1645,7 +1587,7 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection, modifier = [NSArray arrayWithObject: user]; while ((entry = [entries nextObject])) { - sourceRec = [entry _asDictionary]; + sourceRec = [entry asDictionary]; ab = [LDAPSource new]; [ab setSourceID: [sourceRec objectForKey: @"ou"]]; [ab setDisplayName: [sourceRec objectForKey: @"description"]]; diff --git a/SoObjects/SOGo/SOGoGroup.h b/SoObjects/SOGo/SOGoGroup.h index e28cc075f..bf6a8c61d 100644 --- a/SoObjects/SOGo/SOGoGroup.h +++ b/SoObjects/SOGo/SOGoGroup.h @@ -1,6 +1,6 @@ /* SOGoGroup.h - this file is part of SOGo * - * Copyright (C) 2009-2010 Inverse inc. + * Copyright (C) 2009-2012 Inverse inc. * * Author: Ludovic Marcotte * diff --git a/SoObjects/SOGo/SOGoGroup.m b/SoObjects/SOGo/SOGoGroup.m index 031c3d8e7..3d9a9a702 100644 --- a/SoObjects/SOGo/SOGoGroup.m +++ b/SoObjects/SOGo/SOGoGroup.m @@ -1,6 +1,6 @@ /* SOGoGroup.m - this file is part of SOGo * - * Copyright (C) 2009-2011 Inverse inc. + * Copyright (C) 2009-2012 Inverse inc. * * Author: Ludovic Marcotte * @@ -57,6 +57,7 @@ #include "SOGoGroup.h" #import +#import #import #include "SOGoCache.h" @@ -163,15 +164,26 @@ if (entry) { NSArray *classes; - + // We check to see if it's a group - classes = [[entry attributeWithName: @"objectClass"] allStringValues]; + classes = [[entry asDictionary] objectForKey: @"objectclass"]; + + if (classes) + { + int i, c; + + classes = [NSMutableArray arrayWithArray: classes]; + c = [classes count]; + for (i = 0; i < c; i++) + [(id)classes replaceObjectAtIndex: i + withObject: [[classes objectAtIndex: i] lowercaseString]]; + } // Found a group, let's return it. if ([classes containsObject: @"group"] || - [classes containsObject: @"groupOfNames"] || - [classes containsObject: @"groupOfUniqueNames"] || - [classes containsObject: @"posixGroup"]) + [classes containsObject: @"groupofnames"] || + [classes containsObject: @"groupofuniquenames"] || + [classes containsObject: @"posixgroup"]) { o = [[self alloc] initWithIdentifier: theValue domain: domain @@ -192,9 +204,10 @@ { NSMutableArray *dns, *uids, *logins; NSString *dn, *login; + SOGoUserManager *um; + NSDictionary *d; SOGoUser *user; NSArray *o; - SOGoUserManager *um; int i, c; if (!_members) @@ -206,15 +219,16 @@ // We check if it's a static group // Fetch "members" - we get DNs - o = [[_entry attributeWithName: @"member"] allStringValues]; + d = [_entry asDictionary]; + o = [d objectForKey: @"member"]; if (o) [dns addObjectsFromArray: o]; // Fetch "uniqueMembers" - we get DNs - o = [[_entry attributeWithName: @"uniqueMember"] allStringValues]; + o = [d objectForKey: @"uniquemember"]; if (o) [dns addObjectsFromArray: o]; // Fetch "memberUid" - we get UID (like login names) - o = [[_entry attributeWithName: @"memberUid"] allStringValues]; + o = [d objectForKey: @"memberuid"]; if (o) [uids addObjectsFromArray: o]; c = [dns count] + [uids count];