From a91abae53caea3b9d6fb9a9e34ddd9361eaafeab Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Mon, 10 Aug 2009 16:23:21 +0000 Subject: [PATCH] See ChangeLog Monotone-Parent: 8869c98a60f05c3bea1afbb13e7e0be7c12effce Monotone-Revision: 0936c5d1f59eb93c7a73019f0fd42e4e7005e1d9 Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2009-08-10T16:23:21 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 6 ++++++ SoObjects/SOGo/LDAPUserManager.m | 16 +++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index d92371f7e..0a31dbe64 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-08-10 Ludovic Marcotte + + * SoObjects/SOGo/LDAPUserManager.m + Fixed an issue where the LDAP entries wouldn't be + cached properly in memcached. + 2009-08-10 Wolfgang Sourdeau * Tests/webdavlib.py (WebDAVClient._prepare_headers): fixed a typo diff --git a/SoObjects/SOGo/LDAPUserManager.m b/SoObjects/SOGo/LDAPUserManager.m index 780c1a78d..ccfc8566b 100644 --- a/SoObjects/SOGo/LDAPUserManager.m +++ b/SoObjects/SOGo/LDAPUserManager.m @@ -308,9 +308,14 @@ static NSLock *lock = nil; if (!currentUser) { currentUser = [NSMutableDictionary dictionary]; - [[SOGoCache sharedCache] cacheValues: currentUser ofType: @"attributes" forLogin: login]; } + + // It's important to cache the password here as we might have cached the user's entry + // in -contactInfosForUserWithUIDorEmail: and if we don't set the password and recache the + // entry, the password would never be cached for the user unless its entry expires from + // memcached's internal cache. [currentUser setObject: password forKey: @"password"]; + [[SOGoCache sharedCache] cacheValues: currentUser ofType: @"attributes" forLogin: login]; } else checkOK = NO; @@ -448,10 +453,15 @@ static NSLock *lock = nil; if (!([currentUser objectForKey: @"emails"] && [currentUser objectForKey: @"cn"])) { - if (!currentUser) + // We make sure that we either have no occurence of a cache entry or that + // we have an occurence with only a cached password. In the latter case, we + // update the entry with the remaining information and recache the value. + if (!currentUser || ([currentUser count] == 1 && [currentUser objectForKey: @"password"])) { newUser = YES; - currentUser = [NSMutableDictionary dictionary]; + + if (!currentUser) + currentUser = [NSMutableDictionary dictionary]; } else newUser = NO;