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;