- Respect the user domain when dealing with groups

- Renamed protocol MembershipAwareSource to SOGoMembershipSource
pull/263/head
Johannes Kanefendt 2019-12-04 10:37:08 +01:00
parent 278d4ab4cb
commit 948c89f5bb
8 changed files with 44 additions and 28 deletions

View File

@ -425,7 +425,7 @@ static Class iCalEventK = nil;
response: (WOResponse *) theResponse
{
NSMutableDictionary *moduleSettings, *folderShowAlarms, *freeBusyExclusions;
NSString *subscriptionPointer;
NSString *subscriptionPointer, *domain;
NSMutableArray *allUsers;
SOGoUserSettings *us;
NSDictionary *dict;
@ -438,16 +438,18 @@ static Class iCalEventK = nil;
if (rc)
{
#warning Duplicated code from SOGoGCSFolder subscribeUserOrGroup
dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: theIdentifier];
domain = [[context activeUser] domain];
dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: theIdentifier
inDomain: domain];
if (dict && [[dict objectForKey: @"isGroup"] boolValue])
{
id <SOGoSource> source;
source = [[SOGoUserManager sharedUserManager] sourceWithID: [dict objectForKey: @"SOGoSource"]];
if ([source conformsToProtocol:@protocol(MembershipAwareSource)])
if ([source conformsToProtocol:@protocol(SOGoMembershipSource)])
{
NSArray *members = [(id<MembershipAwareSource>)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]];
NSArray *members = [(id<SOGoMembershipSource>)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]];
allUsers = [NSMutableArray array];
for (i = 0; i < [members count]; i++)

View File

@ -1624,7 +1624,7 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
iCalPerson *attendee;
NSException *ex;
SOGoUser *ownerUser, *delegatedUser;
NSString *recurrenceTime, *delegatedUid;
NSString *recurrenceTime, *delegatedUid, *domain;
event = nil;
ex = nil;
@ -1672,7 +1672,9 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
reason: @"delegate is a participant"];
else {
NSDictionary *dict;
dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: [[delegate email] rfc822Email]];
domain = [[context activeUser] domain];
dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: [[delegate email] rfc822Email]
inDomain: domain];
if (dict && [[dict objectForKey: @"isGroup"] boolValue])
ex = [NSException exceptionWithHTTPStatus: 409
reason: @"delegate is a group"];

View File

@ -549,7 +549,8 @@
pool = [[NSAutoreleasePool alloc] init];
}
dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: [currentAttendee rfc822Email]];
dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: [currentAttendee rfc822Email]
inDomain: domain];
if (dict && [[dict objectForKey: @"isGroup"] boolValue])
{
@ -562,9 +563,9 @@
[allAttendees removeObject: currentAttendee];
source = [[SOGoUserManager sharedUserManager] sourceWithID: [dict objectForKey: @"SOGoSource"]];
if ([source conformsToProtocol:@protocol(MembershipAwareSource)])
if ([source conformsToProtocol:@protocol(SOGoMembershipSource)])
{
members = [(id<MembershipAwareSource>)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]];
members = [(id<SOGoMembershipSource>)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]];
for (i = 0; i < [members count]; i++)
{
user = [members objectAtIndex: i];

View File

@ -1424,13 +1424,16 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data)
- (NSString *) _sogoACLUIDToIMAPUID: (NSString *) uid
{
NSString *domain;
NSDictionary *dict;
SOGoUser *user;
if ([uid isEqualToString: defaultUserID])
return uid;
dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: uid];
domain = [[context activeUser] domain];
dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: uid
inDomain: domain];
if (dict && [[dict objectForKey: @"isGroup"] boolValue])
return [[[[context activeUser] domainDefaults] imapAclGroupIdPrefix]

View File

@ -30,7 +30,7 @@
@class NSMutableDictionary;
@class NSString;
@interface LDAPSource : NSObject <SOGoDNSource, MembershipAwareSource>
@interface LDAPSource : NSObject <SOGoDNSource, SOGoMembershipSource>
{
int _queryLimit;
int _queryTimeout;

View File

@ -923,23 +923,25 @@ static NSArray *childRecordFields = nil;
{
NSMutableDictionary *moduleSettings, *folderShowAlarms;
NSMutableArray *folderSubscription;
NSString *subscriptionPointer;
NSString *subscriptionPointer, *domain;
NSMutableArray *allUsers;
SOGoUserSettings *us;
NSDictionary *dict;
BOOL rc;
int i;
dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: theIdentifier];
domain = [[context activeUser] domain];
dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: theIdentifier
inDomain: domain];
if (dict && [[dict objectForKey: @"isGroup"] boolValue])
{
id <SOGoSource> source;
source = [[SOGoUserManager sharedUserManager] sourceWithID: [dict objectForKey: @"SOGoSource"]];
if ([source conformsToProtocol:@protocol(MembershipAwareSource)])
if ([source conformsToProtocol:@protocol(SOGoMembershipSource)])
{
NSArray *members = [(id<MembershipAwareSource>)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]];
NSArray *members = [(id<SOGoMembershipSource>)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]];
allUsers = [NSMutableArray array];
for (i = 0; i < [members count]; i++)
@ -1625,7 +1627,7 @@ static NSArray *childRecordFields = nil;
{
int count, max;
NSDictionary *record;
NSString *currentUID;
NSString *currentUID, *domain;
NSMutableArray *acls;
acls = [NSMutableArray array];
@ -1637,12 +1639,14 @@ static NSArray *childRecordFields = nil;
currentUID = [record valueForKey: @"c_uid"];
if ([currentUID hasPrefix: @"@"])
{
NSString *dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: currentUID];
domain = [[context activeUser] domain];
NSString *dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: currentUID
inDomain: domain];
if (dict)
{
id <SOGoSource> source = [[SOGoUserManager sharedUserManager] sourceWithID: [dict objectForKey: @"SOGoSource"]];
if ([source conformsToProtocol:@protocol(MembershipAwareSource)] &&
[(id<MembershipAwareSource>)(source) groupWithUIDHasMemberWithUID: currentUID memberUid: uid])
if ([source conformsToProtocol:@protocol(SOGoMembershipSource)] &&
[(id<SOGoMembershipSource>)(source) groupWithUIDHasMemberWithUID: currentUID memberUid: uid])
[acls addObject: [record valueForKey: @"c_role"]];
}
}
@ -1751,7 +1755,7 @@ static NSArray *childRecordFields = nil;
forObjectAtPath: (NSArray *) objectPathArray
{
EOQualifier *qualifier;
NSString *uid, *uids, *qs, *objectPath;
NSString *uid, *uids, *qs, *objectPath, *domain;
NSMutableArray *usersAndGroups, *groupsMembers;
NSMutableDictionary *aclsForObject;
@ -1766,19 +1770,21 @@ static NSArray *childRecordFields = nil;
NSDictionary *dict;
uid = [usersAndGroups objectAtIndex: i];
dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: uid];
domain = [[context activeUser] domain];
dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: uid
inDomain: domain];
if (dict && [[dict objectForKey: @"isGroup"] boolValue])
{
id <SOGoSource> source;
source = [[SOGoUserManager sharedUserManager] sourceWithID: [dict objectForKey: @"SOGoSource"]];
if ([source conformsToProtocol:@protocol(MembershipAwareSource)])
if ([source conformsToProtocol:@protocol(SOGoMembershipSource)])
{
NSArray *members;
NSDictionary *user;
unsigned int j;
// Fetch members to remove them from the cache along the group
members = [(id<MembershipAwareSource>)(source) membersForGroupWithUID: uid];
members = [(id<SOGoMembershipSource>)(source) membersForGroupWithUID: uid];
for (j = 0; j < [members count]; j++)
{
user = [members objectAtIndex: j];
@ -1849,7 +1855,7 @@ static NSArray *childRecordFields = nil;
forUser: (NSString *) uid
forObjectAtPath: (NSArray *) objectPathArray
{
NSString *objectPath, *aUID;
NSString *objectPath, *aUID, *domain;
NSMutableArray *newRoles;
objectPath = [objectPathArray componentsJoinedByString: @"/"];
@ -1861,7 +1867,9 @@ static NSArray *childRecordFields = nil;
if (![uid hasPrefix: @"@"])
{
NSDictionary *dict;
dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: uid];
domain = [[context activeUser] domain];
dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: uid
inDomain: domain];
if ([[dict objectForKey: @"isGroup"] boolValue])
{
aUID = [NSString stringWithFormat: @"@%@", uid];

View File

@ -118,7 +118,7 @@
- (void) updateBaseDNFromLogin: (NSString *) theLogin;
@end
@protocol MembershipAwareSource <SOGoSource>
@protocol SOGoMembershipSource <SOGoSource>
- (NSArray *) membersForGroupWithUID: (NSString *) uid;
- (BOOL) groupWithUIDHasMemberWithUID: (NSString *) uid
memberUid: (NSString *) memberUid;

View File

@ -407,9 +407,9 @@
if ([[dict objectForKey: @"isGroup"] boolValue])
{
if ([source conformsToProtocol:@protocol(MembershipAwareSource)])
if ([source conformsToProtocol:@protocol(SOGoMembershipSource)])
{
allUsers = [(id<MembershipAwareSource>)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]];
allUsers = [(id<SOGoMembershipSource>)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]];
max = [allUsers count];
allUsersData = [NSMutableArray arrayWithCapacity: max];
for (i = 0; i < max; i++)