From 347bc411ac8cb1417971e664aa22765cb1a6146d Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 1 Mar 2012 21:57:16 +0000 Subject: [PATCH] Monotone-Parent: ef48f0aa709b92913c131c539cb55562e8c56ebf Monotone-Revision: 40141d367c9c6560edf3b306cee2aa7683dad3ec Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-03-01T21:57:16 --- ChangeLog | 6 ++++++ SoObjects/SOGo/LDAPSource.m | 38 +++++++++++++++++++++++++------------ 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9e3e49f28..017d6a2c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2012-03-01 Wolfgang Sourdeau + * SoObjects/SOGo/LDAPSource.m (_convertRecordToLDAPAttributes): + make sure no field get listed twice in the list of valid field + names by using "removeDoubles". + (_makeLDAPChanges): don't bother checking whether the removed + attributes are strings. + * SoObjects/SOGo/NSArray+Utilities.m (-[NSMutableArray removeDoubles]): new method removing doublons. diff --git a/SoObjects/SOGo/LDAPSource.m b/SoObjects/SOGo/LDAPSource.m index 51db36374..b5cbc146a 100644 --- a/SoObjects/SOGo/LDAPSource.m +++ b/SoObjects/SOGo/LDAPSource.m @@ -1368,6 +1368,7 @@ _convertRecordToLDAPAttributes (LDAPSourceSchema *schema, NSDictionary *ldifReco [validFields addObjectsFromArray: fields]; } } + [validFields removeDoubles]; attributes = [NSMutableArray new]; max = [validFields count]; @@ -1455,8 +1456,10 @@ _convertRecordToLDAPAttributes (LDAPSourceSchema *schema, NSDictionary *ldifReco NS_HANDLER { result = localException; + [result retain]; } NS_ENDHANDLER; + [result autorelease]; } else [self errorWithFormat: @"no value for id field '%@'", IDField]; @@ -1470,12 +1473,12 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection, { NSMutableArray *changes, *attributeNames, *origAttributeNames; NGLdapEntry *origEntry; - NSArray *values; + // NSArray *values; NGLdapAttribute *attribute, *origAttribute; NSString *name; NSDictionary *origAttributes; - NSUInteger count, max, valueCount, valueMax; - BOOL allStrings; + NSUInteger count, max/* , valueCount, valueMax */; + // BOOL allStrings; /* additions and modifications */ origEntry = [ldapConnection entryAtDN: dn @@ -1512,15 +1515,15 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection, origAttribute = [origAttributes objectForKey: name]; /* the attribute must only have string values, otherwise it will anyway be missing from the new record */ - allStrings = YES; - values = [origAttribute allValues]; - valueMax = [values count]; - for (valueCount = 0; allStrings && valueCount < valueMax; valueCount++) - if (![[values objectAtIndex: valueCount] isKindOfClass: NSStringK]) - allStrings = NO; - if (allStrings) - [changes - addObject: [NGLdapModification deleteModification: origAttribute]]; + // allStrings = YES; + // values = [origAttribute allValues]; + // valueMax = [values count]; + // for (valueCount = 0; allStrings && valueCount < valueMax; valueCount++) + // if (![[values objectAtIndex: valueCount] isKindOfClass: NSStringK]) + // allStrings = NO; + // if (allStrings) + [changes + addObject: [NGLdapModification deleteModification: origAttribute]]; } return changes; @@ -1554,8 +1557,10 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection, NS_HANDLER { result = localException; + [result retain]; } NS_ENDHANDLER; + [result autorelease]; } else [self errorWithFormat: @"expected dn for modified record"]; @@ -1580,9 +1585,12 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection, NS_HANDLER { result = localException; + [result retain]; } NS_ENDHANDLER; + [result autorelease]; + return result; } @@ -1720,8 +1728,10 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection, { [self errorWithFormat: @"failed to create addressbook entry"]; result = localException; + [result retain]; } NS_ENDHANDLER; + [result autorelease]; } else result = [NSException exceptionWithName: @"LDAPSourceIOException" @@ -1766,8 +1776,10 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection, { [self errorWithFormat: @"failed to rename addressbook entry"]; result = localException; + [result retain]; } NS_ENDHANDLER; + [result autorelease]; } else result = [NSException exceptionWithName: @"LDAPSourceIOException" @@ -1808,8 +1820,10 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection, { [self errorWithFormat: @"failed to remove addressbook entry"]; result = localException; + [result retain]; } NS_ENDHANDLER; + [result autorelease]; } else result = [NSException exceptionWithName: @"LDAPSourceIOException"