From d32f0d32b867974226a5fe2a15343fc773e6af05 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Mon, 6 Feb 2012 13:55:46 +0000 Subject: [PATCH] Monotone-Parent: c8a56f550a65316cf040c7624d75ba835bbf97c8 Monotone-Revision: 6bc1556981bffd1a4a80e25cdf6ae2e257e57631 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-02-06T13:55:46 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 5 +++++ SoObjects/SOGo/LDAPSource.m | 24 ++++++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8532ae8a7..0e9d73708 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-02-06 Wolfgang Sourdeau + + * SoObjects/SOGo/LDAPSource.m: escape built DNs using the new + -[NSString escapedForLDAPDN] method. + 2012-02-03 Wolfgang Sourdeau * OpenChange/MAPIStoreFolderTable.m diff --git a/SoObjects/SOGo/LDAPSource.m b/SoObjects/SOGo/LDAPSource.m index fa2db52bf..c25978eb2 100644 --- a/SoObjects/SOGo/LDAPSource.m +++ b/SoObjects/SOGo/LDAPSource.m @@ -35,6 +35,7 @@ #import #import #import +#import #import "LDAPSourceSchema.h" #import "NSArray+Utilities.h" @@ -601,7 +602,7 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField } else userDN = [NSString stringWithFormat: @"%@=%@,%@", - IDField, _login, baseDN]; + IDField, [_login escapedForLDAPDN], baseDN]; } if (userDN) @@ -690,7 +691,7 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField userDN = [self _fetchUserDNForLogin: login]; else userDN = [NSString stringWithFormat: @"%@=%@,%@", - IDField, login, baseDN]; + IDField, [login escapedForLDAPDN], baseDN]; if (userDN) { NS_DURING @@ -1439,7 +1440,8 @@ _convertRecordToLDAPAttributes (LDAPSourceSchema *schema, NSDictionary *ldifReco /* since the id might have changed due to the mapping above, we reload the record ID */ aId = [ldifRecord objectForKey: UIDField]; - dn = [NSString stringWithFormat: @"%@=%@,%@", IDField, aId, baseDN]; + dn = [NSString stringWithFormat: @"%@=%@,%@", IDField, + [aId escapedForLDAPDN], baseDN]; attributes = _convertRecordToLDAPAttributes (schema, ldifRecord); newEntry = [[NGLdapEntry alloc] initWithDN: dn @@ -1569,7 +1571,8 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection, NSString *dn; ldapConnection = [self _ldapConnection]; - dn = [NSString stringWithFormat: @"%@=%@,%@", IDField, aId, baseDN]; + dn = [NSString stringWithFormat: @"%@=%@,%@", IDField, + [aId escapedForLDAPDN], baseDN]; NS_DURING { [ldapConnection removeEntryWithDN: dn]; @@ -1608,7 +1611,9 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection, sources = [NSMutableArray array]; ldapConnection = [self _ldapConnection]; - abBaseDN = [NSString stringWithFormat: @"ou=%@,%@=%@,%@", abOU, IDField, user, baseDN]; + abBaseDN = [NSString stringWithFormat: @"ou=%@,%@=%@,%@", + [abOU escapedForLDAPDN], IDField, + [user escapedForLDAPDN], baseDN]; /* test ou=addressbooks entry */ attributes = [NSArray arrayWithObject: @"*"]; @@ -1694,7 +1699,8 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection, if ([self hasUserAddressBooks]) { abDN = [NSString stringWithFormat: @"ou=%@,ou=%@,%@=%@,%@", - newId, abOU, IDField, user, baseDN]; + [newId escapedForLDAPDN], [abOU escapedForLDAPDN], + IDField, [user escapedForLDAPDN], baseDN]; entryRecord = [NSMutableDictionary dictionary]; [entryRecord setObject: @"organizationalUnit" forKey: @"objectclass"]; [entryRecord setObject: newId forKey: @"ou"]; @@ -1740,7 +1746,8 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection, if ([self hasUserAddressBooks]) { abDN = [NSString stringWithFormat: @"ou=%@,ou=%@,%@=%@,%@", - newId, abOU, IDField, user, baseDN]; + [newId escapedForLDAPDN], [abOU escapedForLDAPDN], + IDField, [user escapedForLDAPDN], baseDN]; entryRecord = [NSMutableDictionary dictionary]; [entryRecord setObject: @"organizationalUnit" forKey: @"objectclass"]; [entryRecord setObject: newId forKey: @"ou"]; @@ -1784,7 +1791,8 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection, if ([self hasUserAddressBooks]) { abDN = [NSString stringWithFormat: @"ou=%@,ou=%@,%@=%@,%@", - newId, abOU, IDField, user, baseDN]; + [newId escapedForLDAPDN], [abOU escapedForLDAPDN], + IDField, [user escapedForLDAPDN], baseDN]; ldapConnection = [self _ldapConnection]; NS_DURING {