Revert "Revert "fix(core): added back instance caching for LDAP members""
This reverts commit ca5df1a153
.
pull/280/head
parent
dbf5179e69
commit
056004bca1
|
@ -72,6 +72,7 @@
|
|||
NSDictionary *_contactMapping;
|
||||
NSArray *_contactObjectClasses;
|
||||
NSArray *_groupObjectClasses;
|
||||
NSMutableArray *_members;
|
||||
|
||||
NSDictionary *_modulesConstraints;
|
||||
|
||||
|
|
|
@ -98,6 +98,7 @@ 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;
|
||||
|
@ -142,6 +143,7 @@ static Class NSStringK;
|
|||
[_mailFields release];
|
||||
[_searchFields release];
|
||||
[_groupObjectClasses release];
|
||||
[_members release];
|
||||
[_IMAPHostField release];
|
||||
[_IMAPLoginField release];
|
||||
[_SieveHostField release];
|
||||
|
@ -2033,8 +2035,9 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection,
|
|||
NSAutoreleasePool *pool;
|
||||
int i, c;
|
||||
NGLdapEntry *entry;
|
||||
NSMutableArray *members = nil;
|
||||
|
||||
if (!_members)
|
||||
{
|
||||
if ([uid hasPrefix: @"@"])
|
||||
uid = [uid substringFromIndex: 1];
|
||||
|
||||
|
@ -2042,7 +2045,7 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection,
|
|||
|
||||
if (entry)
|
||||
{
|
||||
members = [NSMutableArray new];
|
||||
_members = [[NSMutableArray alloc] init];
|
||||
uids = [NSMutableArray array];
|
||||
dns = [NSMutableArray array];
|
||||
logins = [NSMutableArray array];
|
||||
|
@ -2081,7 +2084,7 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection,
|
|||
if (user)
|
||||
{
|
||||
[logins addObject: login];
|
||||
[members addObject: [NSDictionary dictionaryWithObject: login
|
||||
[_members addObject: [NSDictionary dictionaryWithObject: login
|
||||
forKey: @"c_uid"]];
|
||||
}
|
||||
[pool release];
|
||||
|
@ -2096,7 +2099,7 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection,
|
|||
if (user)
|
||||
{
|
||||
[logins addObject: login];
|
||||
[members addObject: [NSDictionary dictionaryWithObject: login
|
||||
[_members addObject: [NSDictionary dictionaryWithObject: login
|
||||
forKey: @"c_uid"]];
|
||||
}
|
||||
[pool release];
|
||||
|
@ -2115,8 +2118,9 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection,
|
|||
// We also need to look for labelelURI?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return members;
|
||||
return _members;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -2125,13 +2129,31 @@ _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];
|
||||
|
||||
|
@ -2148,6 +2170,7 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection,
|
|||
|
||||
a = [value componentsSeparatedByString: @","];
|
||||
rc = [a containsObject: memberUid];
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue