(fix) fixed multi-domain support for sogo-tool backup/restore (#2600)
This commit is contained in:
parent
667e38ff0c
commit
5ad3662640
1
NEWS
1
NEWS
|
@ -13,6 +13,7 @@ Bug fixes
|
||||||
- fixed potential organizer highjacking when using EAS (#3131)
|
- fixed potential organizer highjacking when using EAS (#3131)
|
||||||
- properly support big characters in EAS and fix encoding QP EAS error for Outlook (#3082)
|
- properly support big characters in EAS and fix encoding QP EAS error for Outlook (#3082)
|
||||||
- properly encode id of DOM elements in Address Book module (#3239, #3245)
|
- properly encode id of DOM elements in Address Book module (#3239, #3245)
|
||||||
|
- fixed multi-domain support for sogo-tool backup/restore (#2600)
|
||||||
|
|
||||||
2.3.0 (2015-06-01)
|
2.3.0 (2015-06-01)
|
||||||
-------------------
|
-------------------
|
||||||
|
|
|
@ -568,7 +568,7 @@ static Class NSNullK;
|
||||||
// mail: broccoli@example.com
|
// mail: broccoli@example.com
|
||||||
//
|
//
|
||||||
// and authenticates with "foo", using bindFields = (uid, mail) and SOGoEnableDomainBasedUID = YES;
|
// and authenticates with "foo", using bindFields = (uid, mail) and SOGoEnableDomainBasedUID = YES;
|
||||||
// Otherwise, -_sourceCheckLogin:... would have failed because SOGo would to bind using: foo@example.com
|
// Otherwise, -_sourceCheckLogin:... would have failed because SOGo would try to bind using: foo@example.com
|
||||||
//
|
//
|
||||||
if ([[currentUser objectForKey: @"DomainLessLogin"] boolValue])
|
if ([[currentUser objectForKey: @"DomainLessLogin"] boolValue])
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
/* SOGoToolBackup.m - this file is part of SOGo
|
/* SOGoToolBackup.m - this file is part of SOGo
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009-2011 Inverse inc.
|
* Copyright (C) 2009-2015 Inverse inc.
|
||||||
*
|
|
||||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
|
||||||
* Francis Lachapelle <flachapelle@inverse.ca>
|
|
||||||
*
|
*
|
||||||
* This file is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -42,6 +39,7 @@
|
||||||
#import <SOGo/SOGoUserDefaults.h>
|
#import <SOGo/SOGoUserDefaults.h>
|
||||||
#import <SOGo/SOGoUserProfile.h>
|
#import <SOGo/SOGoUserProfile.h>
|
||||||
#import <SOGo/SOGoUserSettings.h>
|
#import <SOGo/SOGoUserSettings.h>
|
||||||
|
#import <SOGo/SOGoSystemDefaults.h>
|
||||||
#import <Contacts/NSDictionary+LDIF.h>
|
#import <Contacts/NSDictionary+LDIF.h>
|
||||||
|
|
||||||
#import "SOGoTool.h"
|
#import "SOGoTool.h"
|
||||||
|
@ -55,7 +53,7 @@
|
||||||
@interface SOGoToolBackup : SOGoTool
|
@interface SOGoToolBackup : SOGoTool
|
||||||
{
|
{
|
||||||
NSString *directory;
|
NSString *directory;
|
||||||
NSArray *userIDs;
|
NSArray *usersToBackup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -83,7 +81,7 @@
|
||||||
if ((self = [super init]))
|
if ((self = [super init]))
|
||||||
{
|
{
|
||||||
directory = nil;
|
directory = nil;
|
||||||
userIDs = nil;
|
usersToBackup = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -92,7 +90,7 @@
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
[directory release];
|
[directory release];
|
||||||
[userIDs release];
|
[usersToBackup release];
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,6 +142,7 @@
|
||||||
lm = [SOGoUserManager sharedUserManager];
|
lm = [SOGoUserManager sharedUserManager];
|
||||||
pool = [[NSAutoreleasePool alloc] init];
|
pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
|
|
||||||
max = [users count];
|
max = [users count];
|
||||||
user = [users objectAtIndex: 0];
|
user = [users objectAtIndex: 0];
|
||||||
if (max == 1 && [user isEqualToString: @"ALL"])
|
if (max == 1 && [user isEqualToString: @"ALL"])
|
||||||
|
@ -199,10 +198,10 @@
|
||||||
}
|
}
|
||||||
[allUsers autorelease];
|
[allUsers autorelease];
|
||||||
|
|
||||||
ASSIGN (userIDs, [allUsers objectsForKey: @"c_uid" notFoundMarker: nil]);
|
ASSIGN (usersToBackup, allUsers);
|
||||||
DESTROY(pool);
|
DESTROY(pool);
|
||||||
|
|
||||||
return ([userIDs count] > 0);
|
return ([usersToBackup count] > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) parseArguments
|
- (BOOL) parseArguments
|
||||||
|
@ -410,19 +409,29 @@
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) exportUser: (NSString *) uid
|
- (BOOL) exportUser: (NSDictionary *) theUser
|
||||||
{
|
{
|
||||||
|
NSString *exportPath, *gcsUID, *ldapUID;
|
||||||
NSMutableDictionary *userRecord;
|
NSMutableDictionary *userRecord;
|
||||||
NSString *exportPath;
|
SOGoSystemDefaults *sd;
|
||||||
|
|
||||||
|
sd = [SOGoSystemDefaults sharedSystemDefaults];
|
||||||
userRecord = [NSMutableDictionary dictionary];
|
userRecord = [NSMutableDictionary dictionary];
|
||||||
exportPath = [directory stringByAppendingPathComponent: uid];
|
|
||||||
|
|
||||||
return ([self extractUserFolders: uid
|
ldapUID = [theUser objectForKey: @"c_uid"];
|
||||||
|
exportPath = [directory stringByAppendingPathComponent: ldapUID];
|
||||||
|
|
||||||
|
gcsUID = [theUser objectForKey: @"c_uid"];
|
||||||
|
|
||||||
|
if ([sd enableDomainBasedUID] && [gcsUID rangeOfString: @"@"].location == NSNotFound)
|
||||||
|
gcsUID = [NSString stringWithFormat: @"%@@%@", gcsUID, [theUser objectForKey: @"c_domain"]];
|
||||||
|
|
||||||
|
|
||||||
|
return ([self extractUserFolders: gcsUID
|
||||||
intoRecord: userRecord]
|
intoRecord: userRecord]
|
||||||
&& [self extractUserLDIFRecord: uid
|
&& [self extractUserLDIFRecord: ldapUID
|
||||||
intoRecord: userRecord]
|
intoRecord: userRecord]
|
||||||
&& [self extractUserPreferences: uid
|
&& [self extractUserPreferences: gcsUID
|
||||||
intoRecord: userRecord]
|
intoRecord: userRecord]
|
||||||
&& [userRecord writeToFile: exportPath
|
&& [userRecord writeToFile: exportPath
|
||||||
atomically: NO]);
|
atomically: NO]);
|
||||||
|
@ -438,10 +447,10 @@
|
||||||
|
|
||||||
pool = [NSAutoreleasePool new];
|
pool = [NSAutoreleasePool new];
|
||||||
|
|
||||||
max = [userIDs count];
|
max = [usersToBackup count];
|
||||||
for (count = 0; rc && count < max; count++)
|
for (count = 0; rc && count < max; count++)
|
||||||
{
|
{
|
||||||
rc = [self exportUser: [userIDs objectAtIndex: count]];
|
rc = [self exportUser: [usersToBackup objectAtIndex: count]];
|
||||||
if ((count % 10) == 0)
|
if ((count % 10) == 0)
|
||||||
[pool emptyPool];
|
[pool emptyPool];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* SOGoToolRestore.m - this file is part of SOGo
|
/* SOGoToolRestore.m - this file is part of SOGo
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009-2014 Inverse inc.
|
* Copyright (C) 2009-2015 Inverse inc.
|
||||||
*
|
*
|
||||||
* This file is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -40,6 +40,7 @@
|
||||||
#import <SOGo/SOGoUserManager.h>
|
#import <SOGo/SOGoUserManager.h>
|
||||||
#import <SOGo/SOGoUserProfile.h>
|
#import <SOGo/SOGoUserProfile.h>
|
||||||
#import <SOGo/SOGoUserSettings.h>
|
#import <SOGo/SOGoUserSettings.h>
|
||||||
|
#import <SOGo/SOGoSystemDefaults.h>
|
||||||
|
|
||||||
#import <NGCards/iCalCalendar.h>
|
#import <NGCards/iCalCalendar.h>
|
||||||
#import <NGCards/NGVCard.h>
|
#import <NGCards/NGVCard.h>
|
||||||
|
@ -65,6 +66,7 @@ typedef enum SOGoToolRestoreMode {
|
||||||
{
|
{
|
||||||
NSString *directory;
|
NSString *directory;
|
||||||
NSString *userID;
|
NSString *userID;
|
||||||
|
NSString *filename;
|
||||||
NSString *restoreFolder;
|
NSString *restoreFolder;
|
||||||
BOOL destructive; /* destructive mode not handled */
|
BOOL destructive; /* destructive mode not handled */
|
||||||
SOGoToolRestoreMode restoreMode;
|
SOGoToolRestoreMode restoreMode;
|
||||||
|
@ -90,6 +92,7 @@ typedef enum SOGoToolRestoreMode {
|
||||||
{
|
{
|
||||||
directory = nil;
|
directory = nil;
|
||||||
userID = nil;
|
userID = nil;
|
||||||
|
filename = nil;
|
||||||
restoreFolder = nil;
|
restoreFolder = nil;
|
||||||
destructive = NO;
|
destructive = NO;
|
||||||
}
|
}
|
||||||
|
@ -101,6 +104,7 @@ typedef enum SOGoToolRestoreMode {
|
||||||
{
|
{
|
||||||
[directory release];
|
[directory release];
|
||||||
[userID release];
|
[userID release];
|
||||||
|
[filename release];
|
||||||
[restoreFolder release];
|
[restoreFolder release];
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
@ -169,13 +173,35 @@ typedef enum SOGoToolRestoreMode {
|
||||||
|
|
||||||
- (BOOL) fetchUserID: (NSString *) identifier
|
- (BOOL) fetchUserID: (NSString *) identifier
|
||||||
{
|
{
|
||||||
BOOL rc;
|
SOGoSystemDefaults *sd;
|
||||||
SOGoUserManager *lm;
|
SOGoUserManager *lm;
|
||||||
NSDictionary *infos;
|
NSDictionary *infos;
|
||||||
|
NSString *uid;
|
||||||
|
|
||||||
|
BOOL rc;
|
||||||
|
|
||||||
lm = [SOGoUserManager sharedUserManager];
|
lm = [SOGoUserManager sharedUserManager];
|
||||||
infos = [lm contactInfosForUserWithUIDorEmail: identifier];
|
infos = [lm contactInfosForUserWithUIDorEmail: identifier];
|
||||||
ASSIGN (userID, [infos objectForKey: @"c_uid"]);
|
uid = nil;
|
||||||
|
|
||||||
|
if (infos)
|
||||||
|
{
|
||||||
|
sd = [SOGoSystemDefaults sharedSystemDefaults];
|
||||||
|
uid = [infos objectForKey: @"c_uid"];
|
||||||
|
|
||||||
|
if ([sd enableDomainBasedUID] && [uid rangeOfString: @"@"].location == NSNotFound)
|
||||||
|
uid = [NSString stringWithFormat: @"%@@%@",
|
||||||
|
[infos objectForKey: @"c_uid"],
|
||||||
|
[infos objectForKey: @"c_domain"]];
|
||||||
|
|
||||||
|
if ([[infos objectForKey: @"DomainLessLogin"] boolValue])
|
||||||
|
ASSIGN(filename, [infos objectForKey: @"c_uid"]);
|
||||||
|
else
|
||||||
|
ASSIGN(filename, uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSIGN (userID, uid);
|
||||||
|
|
||||||
if (userID)
|
if (userID)
|
||||||
rc = YES;
|
rc = YES;
|
||||||
else
|
else
|
||||||
|
@ -613,7 +639,7 @@ typedef enum SOGoToolRestoreMode {
|
||||||
NSString *importPath;
|
NSString *importPath;
|
||||||
BOOL rc;
|
BOOL rc;
|
||||||
|
|
||||||
importPath = [directory stringByAppendingPathComponent: userID];
|
importPath = [directory stringByAppendingPathComponent: filename];
|
||||||
userRecord = [NSDictionary dictionaryWithContentsOfFile: importPath];
|
userRecord = [NSDictionary dictionaryWithContentsOfFile: importPath];
|
||||||
if (userRecord)
|
if (userRecord)
|
||||||
{
|
{
|
||||||
|
@ -631,7 +657,7 @@ typedef enum SOGoToolRestoreMode {
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rc = NO;
|
rc = NO;
|
||||||
NSLog (@"user backup file could not be loaded");
|
NSLog(@"user backup (%@) file could not be loaded", importPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
/* sogo-tool.m - this file is part of SOGo
|
/* sogo-tool.m - this file is part of SOGo
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Inverse inc.
|
* Copyright (C) 2009-2015 Inverse inc.
|
||||||
*
|
|
||||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
|
||||||
*
|
*
|
||||||
* This file is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
Loading…
Reference in a new issue