From 0a315ed33a8b8fb556fee494f4e418a1a767ff2f Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Mon, 8 Sep 2008 14:54:33 +0000 Subject: [PATCH] Monotone-Parent: ee6476408bb7a66b076d467660edc1f7030ecc34 Monotone-Revision: 65a1f239b38d222e483ce7d3070223e073dfdfb3 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-09-08T14:54:33 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 39 +++++++----- SoObjects/SOGo/LDAPSource.m | 115 ++++++++++++++++++++++++------------ 2 files changed, 101 insertions(+), 53 deletions(-) diff --git a/ChangeLog b/ChangeLog index 93967c46b..69113d46b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-09-08 Ludovic Marcotte + + * SoObjects/SOGo/LDAPSource.m ([LDAPSource + -checkLogin:loginToCheckandPassword:passwordToCheck]) + ([LDAPSource -allEntryIDs]) + ([LDAPSource -fetchContactsMatching:match]) + ([LDAPSource -lookupContactEntry:entryID]) + ([LDAPSource -lookupContactEntryWithUIDorEmail:uid]): catch any + LDAP connection failure exception and return an empty result if + such as situation has happened. + 2008-09-05 Wolfgang Sourdeau * SoObjects/Mailer/SOGoMailReply.m: made class a child of @@ -83,7 +94,7 @@ -appendToResponse:_responseinContext:_ctx]): logout from the imap connectin once the response has been appended. -2008-08-29 Ludovic Marcotte +2008-08-29 Ludovic Marcotte * SoObjects/Mailer/SOGoDraftObject.m ([SOGoDraftObject -addRecipients:recipientstoArray:array]): same as below. @@ -1535,11 +1546,11 @@ * SoObjects/SOGo/SOGoCache.[hm]: new cache module implementing a per-connection cache mechanism. -2008-01-16 Ludovic Marcotte +2008-01-16 Ludovic Marcotte * Minor adjustments / bug fixes to previous commit. -2008-01-14 Ludovic Marcotte +2008-01-14 Ludovic Marcotte * Added files related to the custom recurrence editor of the SOGo Web interface. The CSS @@ -1559,7 +1570,7 @@ -composeAction]): the mailto form parameter can now be a comma-separated list of email addresses. -2007-12-21 Ludovic Marcotte +2007-12-21 Ludovic Marcotte * UI/Contacts/UIxContactView.m Modified -secondaryEmail so that we always get @@ -1610,7 +1621,7 @@ * UI/MailerUI/UIxMailMainFrame.m ([UIxMailMainFrame -composeAction]): fixed URL when no recipient is specified. -2007-12-14 Ludovic Marcotte +2007-12-14 Ludovic Marcotte * SoObjects/Appointments/SOGoCalendarComponent.m We set headers in lowercase so that they get properly @@ -1684,7 +1695,7 @@ -_loadAttendees]): added the retrieval of attendees state on current event. -2007-12-12 Ludovic Marcotte +2007-12-12 Ludovic Marcotte * UI/MailPartViewers/UIxMailRenderingContext.{h,m} Removed template caching which added very little @@ -1721,7 +1732,7 @@ @{tableName} substitution variable to be substitued with the real table name obtained from the configuration variables. -2007-12-07 Ludovic Marcotte +2007-12-07 Ludovic Marcotte * UI/MailPartViewers/UIxMailRenderingContext.m We treat multipart/appledouble like multipart/mixed @@ -1851,7 +1862,7 @@ that implement a custom DAV-based protocol query for querying folder based on specified attributes. -2007-12-03 Ludovic Marcotte +2007-12-03 Ludovic Marcotte * Main/NSException+Stacktrace.{h,m} - new files to handle automatic stack trace generation @@ -2002,7 +2013,7 @@ * UI/MailPartViewers/UIxMailPartICalViewer.m ([-fallbackStringEncoding]): removed method. -2007-11-25 Ludovic Marcotte +2007-11-25 Ludovic Marcotte * SoObjects/Mailer/SOGoMailForward.m Use [sourceMail decodedSubject] instead of [sourceMail subject] @@ -2160,7 +2171,7 @@ ([UIxMailPartICalActions -deleteFromCalendarAction]): actually delete the found object. -2007-11-18 Ludovic Marcotte +2007-11-18 Ludovic Marcotte * SoObjects/Mailer/SOGoMailBodyPart.m SoObjects/Mailer/SOGoMailObject.m @@ -2288,7 +2299,7 @@ * UI/Common/UIxAppNavView.m: removed useless class module. -2007-11-16 Ludovic Marcotte +2007-11-16 Ludovic Marcotte * SoObjects/Mailer/SOGoMailBaseObject.m Fixed typo. @@ -2316,7 +2327,7 @@ * UI/WebServerResources/MailerUI.css CSS fix for table views. -2007-11-15 Ludovic Marcotte +2007-11-15 Ludovic Marcotte * UI/WebServerResources/MailerUI.js We now check for empty selection and warn the @@ -5486,7 +5497,7 @@ removed anyway. ([UIxComponent -applicationPath]): same as above. -2007-02-08 Ludovic Marcotte +2007-02-08 Ludovic Marcotte * SoObjects/Mailer/SOGoMailFolder.m: priorize the lookup of folders before doing the one on messages. @@ -5501,7 +5512,7 @@ SoObjects/common.make, UI/common.make: install in GNUSTEP_INSTALLATION_DIR instead of GNUSTEP_USER_DIR. -2007-02-07 Ludovic Marcotte +2007-02-07 Ludovic Marcotte * UI/Scheduler/English.lproj/Localizable.strings: fixed typo for "Agendas" diff --git a/SoObjects/SOGo/LDAPSource.m b/SoObjects/SOGo/LDAPSource.m index 899972d7e..80650e5e9 100644 --- a/SoObjects/SOGo/LDAPSource.m +++ b/SoObjects/SOGo/LDAPSource.m @@ -1,6 +1,6 @@ /* LDAPSource.m - this file is part of SOGo * - * Copyright (C) 2007 Inverse groupe conseil + * Copyright (C) 2007-2008 Inverse inc. * * Author: Wolfgang Sourdeau * @@ -230,17 +230,30 @@ static int sizeLimit; ASSIGN (bindFields, newBindFields); } -- (void) _initLDAPConnection +- (BOOL) _initLDAPConnection { - ldapConnection = [[NGLdapConnection alloc] initWithHostName: hostname - port: port]; - [ldapConnection bindWithMethod: @"simple" - binddn: bindDN - credentials: password]; - if (sizeLimit > 0) - [ldapConnection setQuerySizeLimit: sizeLimit]; - if (timeLimit > 0) - [ldapConnection setQueryTimeLimit: timeLimit]; + BOOL b; + + NS_DURING + { + ldapConnection = [[NGLdapConnection alloc] initWithHostName: hostname + port: port]; + [ldapConnection bindWithMethod: @"simple" + binddn: bindDN + credentials: password]; + if (sizeLimit > 0) + [ldapConnection setQuerySizeLimit: sizeLimit]; + if (timeLimit > 0) + [ldapConnection setQueryTimeLimit: timeLimit]; + b = YES; + } + NS_HANDLER + { + b = NO; + } + NS_ENDHANDLER; + + return b; } /* user management */ @@ -266,17 +279,23 @@ static int sizeLimit; NSEnumerator *entries; NGLdapEntry *userEntry; - [self _initLDAPConnection]; - entries = [ldapConnection deepSearchAtBaseDN: baseDN - qualifier: - [self _qualifierForBindFilter: loginToCheck] - attributes: [NSArray arrayWithObject: @"dn"]]; - userEntry = [entries nextObject]; + if ([self _initLDAPConnection]) + { + entries = [ldapConnection deepSearchAtBaseDN: baseDN + qualifier: + [self _qualifierForBindFilter: loginToCheck] + attributes: [NSArray arrayWithObject: @"dn"]]; + userEntry = [entries nextObject]; + } + else + userEntry = nil; + if (userEntry) userDN = [userEntry dn]; else userDN = nil; - [ldapConnection release]; + + [ldapConnection autorelease]; return userDN; } @@ -399,10 +418,13 @@ static int sizeLimit; ids = [NSMutableArray array]; - [self _initLDAPConnection]; - entries = [ldapConnection deepSearchAtBaseDN: baseDN - qualifier: nil - attributes: [NSArray arrayWithObject: IDField]]; + if ([self _initLDAPConnection]) + entries = [ldapConnection deepSearchAtBaseDN: baseDN + qualifier: nil + attributes: [NSArray arrayWithObject: IDField]]; + else + entries = nil; + if (entries) { currentEntry = [entries nextObject]; @@ -415,7 +437,8 @@ static int sizeLimit; currentEntry = [entries nextObject]; } } - [ldapConnection release]; + + [ldapConnection autorelease]; return ids; } @@ -518,10 +541,13 @@ static int sizeLimit; if ([match length] > 0) { - [self _initLDAPConnection]; - entries = [ldapConnection deepSearchAtBaseDN: baseDN - qualifier: [self _qualifierForFilter: match] - attributes: [self _searchAttributes]]; + if ([self _initLDAPConnection]) + entries = [ldapConnection deepSearchAtBaseDN: baseDN + qualifier: [self _qualifierForFilter: match] + attributes: [self _searchAttributes]]; + else + entries = nil; + if (entries) { currentEntry = [entries nextObject]; @@ -532,6 +558,7 @@ static int sizeLimit; currentEntry = [entries nextObject]; } } + [ldapConnection release]; } @@ -547,14 +574,18 @@ static int sizeLimit; if ([entryID length] > 0) { - [self _initLDAPConnection]; - ldapEntry - = [ldapConnection entryAtDN: [NSString stringWithFormat: @"%@=%@,%@", - IDField, entryID, baseDN] - attributes: [self _searchAttributes]]; + if ([self _initLDAPConnection]) + ldapEntry + = [ldapConnection entryAtDN: [NSString stringWithFormat: @"%@=%@,%@", + IDField, entryID, baseDN] + attributes: [self _searchAttributes]]; + else + ldapEntry = nil; + if (ldapEntry) contactEntry = [self _convertLDAPEntryToContact: ldapEntry]; - [ldapConnection release]; + + [ldapConnection autorelease]; } return contactEntry; @@ -571,14 +602,20 @@ static int sizeLimit; if ([uid length] > 0) { - [self _initLDAPConnection]; - qualifier = [self _qualifierForUIDFilter: uid]; - entries = [ldapConnection deepSearchAtBaseDN: baseDN - qualifier: qualifier - attributes: [self _searchAttributes]]; - ldapEntry = [entries nextObject]; + if ([self _initLDAPConnection]) + { + qualifier = [self _qualifierForUIDFilter: uid]; + entries = [ldapConnection deepSearchAtBaseDN: baseDN + qualifier: qualifier + attributes: [self _searchAttributes]]; + ldapEntry = [entries nextObject]; + } + else + ldapEntry = nil; + if (ldapEntry) contactEntry = [self _convertLDAPEntryToContact: ldapEntry]; + [ldapConnection release]; }