From 3950e9d4c33417cbf821f5554e566e6a68b7d0b0 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Tue, 4 Feb 2014 21:03:11 -0500 Subject: [PATCH] Moved DN cache to SOGoCache --- NEWS | 1 + SoObjects/SOGo/LDAPSource.h | 4 +--- SoObjects/SOGo/LDAPSource.m | 14 +++++++------- SoObjects/SOGo/SOGoCache.h | 12 ++++++++---- SoObjects/SOGo/SOGoCache.m | 27 ++++++++++++++++++++++----- 5 files changed, 39 insertions(+), 19 deletions(-) diff --git a/NEWS b/NEWS index b8a0b1db4..c4fe757ea 100644 --- a/NEWS +++ b/NEWS @@ -26,6 +26,7 @@ Enhancements - visually identify users with no freebusy information in autocompletion widget of attendees editor (#2565) - respect occurences of recurrent events when deleting selected events (#1950) - improved confirmation dialog box when deleting events and tasks + - moved the DN cache to SOGoCache - avoiding sogod restarts after RDN operations Bug fixes - don't load 'background' attribute (#2437) diff --git a/SoObjects/SOGo/LDAPSource.h b/SoObjects/SOGo/LDAPSource.h index 6dd6a2325..982c39543 100644 --- a/SoObjects/SOGo/LDAPSource.h +++ b/SoObjects/SOGo/LDAPSource.h @@ -1,6 +1,6 @@ /* LDAPSource.h - this file is part of SOGo * - * Copyright (C) 2007-2013 Inverse inc. + * Copyright (C) 2007-2014 Inverse inc. * * 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 @@ -79,8 +79,6 @@ BOOL passwordPolicy; - NSMutableDictionary *_dnCache; - /* resources handling */ NSString *kindField; NSString *multipleBookingsField; diff --git a/SoObjects/SOGo/LDAPSource.m b/SoObjects/SOGo/LDAPSource.m index 0f0cd8915..cb664a6b9 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-2013 Inverse inc. + * Copyright (C) 2007-2014 Inverse inc. * * 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 @@ -37,6 +37,7 @@ #import "NSArray+Utilities.h" #import "NSString+Utilities.h" #import "NSString+Crypto.h" +#import "SOGoCache.h" #import "SOGoDomainDefaults.h" #import "SOGoSystemDefaults.h" @@ -118,7 +119,6 @@ static Class NSStringK; MSExchangeHostname = nil; - _dnCache = [[NSMutableDictionary alloc] init]; modifiers = nil; } @@ -155,7 +155,6 @@ static Class NSStringK; [_scope release]; [searchAttributes release]; [domain release]; - [_dnCache release]; [kindField release]; [multipleBookingsField release]; [MSExchangeHostname release]; @@ -528,7 +527,7 @@ static Class NSStringK; if (queryTimeout > 0) [bindConnection setQueryTimeLimit: queryTimeout]; - userDN = [_dnCache objectForKey: _login]; + userDN = [[SOGoCache sharedCache] distinguishedNameForLogin: _login]; if (!userDN) { @@ -551,8 +550,9 @@ static Class NSStringK; if (userDN) { // We cache the _login <-> userDN entry to speed up things - [_dnCache setObject: userDN forKey: _login]; - + [[SOGoCache sharedCache] setDistinguishedName: userDN + forLogin: _login]; + if (!passwordPolicy) didBind = [bindConnection bindWithMethod: @"simple" binddn: userDN @@ -1238,7 +1238,7 @@ static Class NSStringK; - (NSString *) lookupDNByLogin: (NSString *) theLogin { - return [_dnCache objectForKey: theLogin]; + return [[SOGoCache sharedCache] distinguishedNameForLogin: theLogin]; } - (NGLdapEntry *) _lookupGroupEntryByAttributes: (NSArray *) theAttributes diff --git a/SoObjects/SOGo/SOGoCache.h b/SoObjects/SOGo/SOGoCache.h index af6be9787..648fc4b60 100644 --- a/SoObjects/SOGo/SOGoCache.h +++ b/SoObjects/SOGo/SOGoCache.h @@ -1,9 +1,6 @@ /* SOGoCache.h - this file is part of SOGo * - * Copyright (C) 2008-2013 Inverse inc. - * - * Author: Wolfgang Sourdeau - * Ludovic Marcotte + * Copyright (C) 2008-2014 Inverse inc. * * 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 @@ -109,6 +106,11 @@ - (NSDictionary *) messageSubmissionsCountForLogin: (NSString *) theLogin; +- (NSString *) distinguishedNameForLogin: (NSString *) theLogin; + +- (void) setDistinguishedName: (NSString *) theDN + forLogin: (NSString *) theLogin; + // // CAS support // @@ -124,7 +126,9 @@ - (void) removeCASSessionWithTicket: (NSString *) ticket; +// // SAML2 support +// - (NSDictionary *) saml2LoginDumpsForIdentifier: (NSString *) identifier; - (void) setSaml2LoginDumps: (NSDictionary *) dump forIdentifier: (NSString *) identifier; diff --git a/SoObjects/SOGo/SOGoCache.m b/SoObjects/SOGo/SOGoCache.m index 6808721df..dac0b2d85 100644 --- a/SoObjects/SOGo/SOGoCache.m +++ b/SoObjects/SOGo/SOGoCache.m @@ -1,9 +1,6 @@ /* SOGoCache.m - this file is part of SOGo * - * Copyright (C) 2008-2013 Inverse inc. - * - * Author: Wolfgang Sourdeau - * Ludovic Marcotte + * Copyright (C) 2008-2014 Inverse inc. * * 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 @@ -34,6 +31,9 @@ * +defaults value = NSDictionary instance > user's defaults * +settings value = NSDictionary instance > user's settings * +attributes value = NSMutableDictionary instance > user's LDAP attributes + * +failedlogins value = + * +messagesubmissions value = + * +dn value = NSString instance > cached user's DN * +acl value = NSDictionary instance > ACLs on an object at specified path * + value = NSString instance (array components separated by ",") or group member logins for a specific group in domain * cas-id:< > value = @@ -435,7 +435,9 @@ static memcached_st *handle = NULL; } // -// +// Try to hit the local cache. If it misses, it'll +// then try memcached. If it hits memcached, it'll +// populate the local cache. // - (NSString *) _valuesOfType: (NSString *) theType forKey: (NSString *) theKey @@ -604,6 +606,21 @@ static memcached_st *handle = NULL; return d; } +// +// DN caching +// +- (NSString *) distinguishedNameForLogin: (NSString *) theLogin +{ + return [self _valuesOfType: @"dn" forKey: theLogin]; +} + +- (void) setDistinguishedName: (NSString *) theDN + forLogin: (NSString *) theLogin +{ + [self _cacheValues: theDN + ofType: @"dn" + forKey: theLogin]; +} // // CAS session support