Revert "Revert "Revert "fix(core): added back instance caching for LDAP members"""
This reverts commit 056004bca1
.
feature/mail-identities
parent
cb08abfa67
commit
cddfac82dd
|
@ -72,7 +72,6 @@
|
|||
NSDictionary *_contactMapping;
|
||||
NSArray *_contactObjectClasses;
|
||||
NSArray *_groupObjectClasses;
|
||||
NSMutableArray *_members;
|
||||
|
||||
NSDictionary *_modulesConstraints;
|
||||
NSArray *_lookupFields;
|
||||
|
|
|
@ -98,7 +98,6 @@ static Class NSStringK;
|
|||
// "name" expands to sn, displayname and cn
|
||||
_searchFields = [[NSArray arrayWithObjects: @"name", @"mail", @"telephonenumber", nil] retain];
|
||||
_groupObjectClasses = [[NSArray arrayWithObjects: @"group", @"groupofnames", @"groupofuniquenames", @"posixgroup", nil] retain];
|
||||
_members = nil;
|
||||
_IMAPHostField = nil;
|
||||
_IMAPLoginField = nil;
|
||||
_SieveHostField = nil;
|
||||
|
@ -145,7 +144,6 @@ static Class NSStringK;
|
|||
[_mailFields release];
|
||||
[_searchFields release];
|
||||
[_groupObjectClasses release];
|
||||
[_members release];
|
||||
[_IMAPHostField release];
|
||||
[_IMAPLoginField release];
|
||||
[_SieveHostField release];
|
||||
|
@ -2039,9 +2037,8 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection,
|
|||
NSAutoreleasePool *pool;
|
||||
int i, c;
|
||||
NGLdapEntry *entry;
|
||||
NSMutableArray *members = nil;
|
||||
|
||||
if (!_members)
|
||||
{
|
||||
if ([uid hasPrefix: @"@"])
|
||||
uid = [uid substringFromIndex: 1];
|
||||
|
||||
|
@ -2049,7 +2046,7 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection,
|
|||
|
||||
if (entry)
|
||||
{
|
||||
_members = [[NSMutableArray alloc] init];
|
||||
members = [NSMutableArray new];
|
||||
uids = [NSMutableArray array];
|
||||
dns = [NSMutableArray array];
|
||||
logins = [NSMutableArray array];
|
||||
|
@ -2088,7 +2085,7 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection,
|
|||
if (user)
|
||||
{
|
||||
[logins addObject: login];
|
||||
[_members addObject: [NSDictionary dictionaryWithObject: login
|
||||
[members addObject: [NSDictionary dictionaryWithObject: login
|
||||
forKey: @"c_uid"]];
|
||||
}
|
||||
[pool release];
|
||||
|
@ -2103,7 +2100,7 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection,
|
|||
if (user)
|
||||
{
|
||||
[logins addObject: login];
|
||||
[_members addObject: [NSDictionary dictionaryWithObject: login
|
||||
[members addObject: [NSDictionary dictionaryWithObject: login
|
||||
forKey: @"c_uid"]];
|
||||
}
|
||||
[pool release];
|
||||
|
@ -2122,9 +2119,8 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection,
|
|||
// We also need to look for labelelURI?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _members;
|
||||
return members;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -2133,31 +2129,13 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection,
|
|||
- (BOOL) groupWithUIDHasMemberWithUID: (NSString *) uid
|
||||
memberUid: (NSString *) memberUid
|
||||
{
|
||||
|
||||
BOOL rc;
|
||||
NSString *key, *value;;
|
||||
NSArray *a;
|
||||
|
||||
rc = NO;
|
||||
|
||||
// If _members is initialized, we use it as it's very accurate.
|
||||
// Otherwise, we fallback on memcached in order to avoid
|
||||
// decomposing the group all the time just to see if a user
|
||||
// is a member of it.
|
||||
if (_members)
|
||||
{
|
||||
NSString *currentUID;
|
||||
int count, max;
|
||||
|
||||
max = [_members count];
|
||||
for (count = 0; !rc && count < max; count++)
|
||||
{
|
||||
currentUID = [[_members objectAtIndex: count] objectForKey: @"c_uid"];
|
||||
rc = [memberUid isEqualToString: currentUID];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString *key, *value;
|
||||
NSArray *a;
|
||||
|
||||
if ([uid hasPrefix: @"@"])
|
||||
uid = [uid substringFromIndex: 1];
|
||||
|
||||
|
@ -2174,7 +2152,6 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection,
|
|||
|
||||
a = [value componentsSeparatedByString: @","];
|
||||
rc = [a containsObject: memberUid];
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue