From 8508800ca5f584f6523d22064fdc402df923d704 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Mon, 21 Mar 2011 18:04:50 +0000 Subject: [PATCH] See ChangeLog Monotone-Parent: 6e7ac4cd1529c1ca1209faeb43583ee333facec8 Monotone-Revision: fdd87c8990a184548d84798a93d2b2df80f30651 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2011-03-21T18:04:50 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 8 +++++ Tools/SOGoToolBackup.m | 69 ++++++++++++++++++++++++++++++------------ 2 files changed, 58 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 355c20228..779b32066 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-03-21 Francis Lachapelle + + * Tools/SOGoToolBackup.m (-fetchUserIDs:): when choosing to backup + all users, fetch the users list from the folder info table instead + of the configured sources. This fixes an issue when trying to + retrieve the users from LDAP sources that limit the number + of results. + 2011-03-20 Wolfgang Sourdeau * OpenChange/MAPIStoreCalendarMessage.m diff --git a/Tools/SOGoToolBackup.m b/Tools/SOGoToolBackup.m index 2b1d416fc..5b2c6588e 100644 --- a/Tools/SOGoToolBackup.m +++ b/Tools/SOGoToolBackup.m @@ -1,8 +1,9 @@ /* SOGoToolBackup.m - this file is part of SOGo * - * Copyright (C) 2009-2010 Inverse inc. + * Copyright (C) 2009-2011 Inverse inc. * * Author: Wolfgang Sourdeau + * Francis Lachapelle * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -139,28 +140,58 @@ max = [users count]; user = [users objectAtIndex: 0]; if (max == 1 && [user isEqualToString: @"ALL"]) - allUsers = [lm fetchUsersMatching: @"." inDomain: nil]; - else { - allUsers = [NSMutableArray new]; - for (count = 0; count < max; count++) - { - if (count > 0 && count%100 == 0) - { - DESTROY(pool); - pool = [[NSAutoreleasePool alloc] init]; - } + GCSFolderManager *fm; + GCSChannelManager *cm; + NSURL *folderLocation; + EOAdaptorChannel *fc; + NSArray *attrs; + NSMutableArray *allSqlUsers; + NSString *sql; - user = [users objectAtIndex: count]; - infos = [lm contactInfosForUserWithUIDorEmail: user]; - if (infos) - [allUsers addObject: infos]; - else - NSLog (@"user '%@' unknown", user); - } - [allUsers autorelease]; + fm = [GCSFolderManager defaultFolderManager]; + cm = [fm channelManager]; + folderLocation = [fm folderInfoLocation]; + fc = [cm acquireOpenChannelForURL: folderLocation]; + if (fc) + { + allSqlUsers = [NSMutableArray new]; + sql + = [NSString stringWithFormat: @"SELECT DISTINCT c_path2 FROM %@", + [folderLocation gcsTableName]]; + [fc evaluateExpressionX: sql]; + attrs = [fc describeResults: NO]; + while ((infos = [fc fetchAttributes: attrs withZone: NULL])) + { + user = [infos objectForKey: @"c_path2"]; + if (user) + [allSqlUsers addObject: user]; + } + [cm releaseChannel: fc]; + + users = allSqlUsers; + max = [users count]; + } } + allUsers = [NSMutableArray new]; + for (count = 0; count < max; count++) + { + if (count > 0 && count%100 == 0) + { + DESTROY(pool); + pool = [[NSAutoreleasePool alloc] init]; + } + + user = [users objectAtIndex: count]; + infos = [lm contactInfosForUserWithUIDorEmail: user]; + if (infos) + [allUsers addObject: infos]; + else + NSLog (@"user '%@' unknown", user); + } + [allUsers autorelease]; + ASSIGN (userIDs, [allUsers objectsForKey: @"c_uid" notFoundMarker: nil]); DESTROY(pool);