fix(core): added back instance caching for LDAP members
This commit is contained in:
parent
4d42e3f176
commit
b94175cc0c
|
@ -72,6 +72,7 @@
|
||||||
NSDictionary *_contactMapping;
|
NSDictionary *_contactMapping;
|
||||||
NSArray *_contactObjectClasses;
|
NSArray *_contactObjectClasses;
|
||||||
NSArray *_groupObjectClasses;
|
NSArray *_groupObjectClasses;
|
||||||
|
NSMutableArray *_members;
|
||||||
|
|
||||||
NSDictionary *_modulesConstraints;
|
NSDictionary *_modulesConstraints;
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,7 @@ static Class NSStringK;
|
||||||
// "name" expands to sn, displayname and cn
|
// "name" expands to sn, displayname and cn
|
||||||
_searchFields = [[NSArray arrayWithObjects: @"name", @"mail", @"telephonenumber", nil] retain];
|
_searchFields = [[NSArray arrayWithObjects: @"name", @"mail", @"telephonenumber", nil] retain];
|
||||||
_groupObjectClasses = [[NSArray arrayWithObjects: @"group", @"groupofnames", @"groupofuniquenames", @"posixgroup", nil] retain];
|
_groupObjectClasses = [[NSArray arrayWithObjects: @"group", @"groupofnames", @"groupofuniquenames", @"posixgroup", nil] retain];
|
||||||
|
_members = nil;
|
||||||
_IMAPHostField = nil;
|
_IMAPHostField = nil;
|
||||||
_IMAPLoginField = nil;
|
_IMAPLoginField = nil;
|
||||||
_SieveHostField = nil;
|
_SieveHostField = nil;
|
||||||
|
@ -142,6 +143,7 @@ static Class NSStringK;
|
||||||
[_mailFields release];
|
[_mailFields release];
|
||||||
[_searchFields release];
|
[_searchFields release];
|
||||||
[_groupObjectClasses release];
|
[_groupObjectClasses release];
|
||||||
|
[_members release];
|
||||||
[_IMAPHostField release];
|
[_IMAPHostField release];
|
||||||
[_IMAPLoginField release];
|
[_IMAPLoginField release];
|
||||||
[_SieveHostField release];
|
[_SieveHostField release];
|
||||||
|
@ -2033,8 +2035,9 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection,
|
||||||
NSAutoreleasePool *pool;
|
NSAutoreleasePool *pool;
|
||||||
int i, c;
|
int i, c;
|
||||||
NGLdapEntry *entry;
|
NGLdapEntry *entry;
|
||||||
NSMutableArray *members = nil;
|
|
||||||
|
|
||||||
|
if (!_members)
|
||||||
|
{
|
||||||
if ([uid hasPrefix: @"@"])
|
if ([uid hasPrefix: @"@"])
|
||||||
uid = [uid substringFromIndex: 1];
|
uid = [uid substringFromIndex: 1];
|
||||||
|
|
||||||
|
@ -2042,7 +2045,7 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection,
|
||||||
|
|
||||||
if (entry)
|
if (entry)
|
||||||
{
|
{
|
||||||
members = [NSMutableArray new];
|
_members = [[NSMutableArray alloc] init];
|
||||||
uids = [NSMutableArray array];
|
uids = [NSMutableArray array];
|
||||||
dns = [NSMutableArray array];
|
dns = [NSMutableArray array];
|
||||||
logins = [NSMutableArray array];
|
logins = [NSMutableArray array];
|
||||||
|
@ -2081,7 +2084,7 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection,
|
||||||
if (user)
|
if (user)
|
||||||
{
|
{
|
||||||
[logins addObject: login];
|
[logins addObject: login];
|
||||||
[members addObject: [NSDictionary dictionaryWithObject: login
|
[_members addObject: [NSDictionary dictionaryWithObject: login
|
||||||
forKey: @"c_uid"]];
|
forKey: @"c_uid"]];
|
||||||
}
|
}
|
||||||
[pool release];
|
[pool release];
|
||||||
|
@ -2096,7 +2099,7 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection,
|
||||||
if (user)
|
if (user)
|
||||||
{
|
{
|
||||||
[logins addObject: login];
|
[logins addObject: login];
|
||||||
[members addObject: [NSDictionary dictionaryWithObject: login
|
[_members addObject: [NSDictionary dictionaryWithObject: login
|
||||||
forKey: @"c_uid"]];
|
forKey: @"c_uid"]];
|
||||||
}
|
}
|
||||||
[pool release];
|
[pool release];
|
||||||
|
@ -2115,8 +2118,9 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection,
|
||||||
// We also need to look for labelelURI?
|
// We also need to look for labelelURI?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return members;
|
return _members;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -2125,13 +2129,31 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection,
|
||||||
- (BOOL) groupWithUIDHasMemberWithUID: (NSString *) uid
|
- (BOOL) groupWithUIDHasMemberWithUID: (NSString *) uid
|
||||||
memberUid: (NSString *) memberUid
|
memberUid: (NSString *) memberUid
|
||||||
{
|
{
|
||||||
|
|
||||||
BOOL rc;
|
BOOL rc;
|
||||||
NSString *key, *value;;
|
|
||||||
NSArray *a;
|
|
||||||
|
|
||||||
rc = NO;
|
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: @"@"])
|
if ([uid hasPrefix: @"@"])
|
||||||
uid = [uid substringFromIndex: 1];
|
uid = [uid substringFromIndex: 1];
|
||||||
|
|
||||||
|
@ -2148,6 +2170,7 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection,
|
||||||
|
|
||||||
a = [value componentsSeparatedByString: @","];
|
a = [value componentsSeparatedByString: @","];
|
||||||
rc = [a containsObject: memberUid];
|
rc = [a containsObject: memberUid];
|
||||||
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue