From 42e149a3b28779d5ec97408ae453cf77697616b6 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Wed, 22 Oct 2008 20:50:27 +0000 Subject: [PATCH] Improved error message when misconfiguring the SOGoLDAPSources. Monotone-Parent: 24fe8bbb9b61c347ef798b9f6e888d08bf6aa660 Monotone-Revision: 49bc68e8b74862055ad4e2b93e3b0c4b0e791801 Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2008-10-22T20:50:27 Monotone-Branch: ca.inverse.sogo --- SoObjects/SOGo/LDAPUserManager.m | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/SoObjects/SOGo/LDAPUserManager.m b/SoObjects/SOGo/LDAPUserManager.m index 85c3f7b95..79b3561b3 100644 --- a/SoObjects/SOGo/LDAPUserManager.m +++ b/SoObjects/SOGo/LDAPUserManager.m @@ -111,16 +111,21 @@ static BOOL forceImapLoginWithEmail = NO; - (void) _prepareLDAPSourcesWithDefaults: (NSUserDefaults *) ud { - NSArray *udSources; + id udSources; unsigned int count, max; sources = [NSMutableDictionary new]; sourcesMetadata = [NSMutableDictionary new]; udSources = [ud arrayForKey: @"SOGoLDAPSources"]; - max = [udSources count]; - for (count = 0; count < max; count++) - [self _registerSource: [udSources objectAtIndex: count]]; + + if (udSources && [udSources isKindOfClass: [NSArray class]]) { + max = [udSources count]; + for (count = 0; count < max; count++) + [self _registerSource: [udSources objectAtIndex: count]]; + } else { + [self errorWithFormat: @"SOGoLDAPSources is not defined or it is not an array. Check your defaults."]; + } } - (id) init