/// <summary> /// Gets the current security associations for a list of groups against a particular securable object /// </summary> /// <param name="webUrl">The URL for the SP site</param> /// <param name="glGroups">A list of groups to get the security assocations for</param> /// <param name="securableObject">An object that contains the Parent and Object ID's /// SecurableParentUid: The ID of the securable parent (Guid.Empty for projects), /// SecurableObjectUid: The ID of the securable object (root map UID or project UID if securing a project)</param> /// <returns>A dictionary of security association, Key: the group, Value: True if the group has an assocation. (wrapped in a Response Object to indicate if any errors occured)</returns> internal GetSecurityAssociationsResponse GetSecurityAssociations(IEnumerable <GlymaSecurityGroup> glGroups, GlymaSecurableObject securableObject) { GetSecurityAssociationsResponse result = new GetSecurityAssociationsResponse() { HasError = false }; if (this.CurrentUser.IsUserSecurityManager()) { SecurityAssociations securityAssociations = new SecurityAssociations(); Dictionary <GlymaSecurityGroup, bool> results = new Dictionary <GlymaSecurityGroup, bool>(); SecurableContext securableContext = GetSecurableContext(); int securableContextId = securableContext.SecurableContextId; GlymaSecurableObjectContext securableObjectContext = new GlymaSecurableObjectContext(this, securableContextId, securableObject); bool isInherited = securableObjectContext.GetIsInherited(); foreach (GlymaSecurityGroup glymaSecurityGroup in glGroups) { try { GlymaSecurityAssociationContext securityAssociationContext = new GlymaSecurityAssociationContext(this, glymaSecurityGroup, securableObject); bool response = securityAssociationContext.HasAssociation(); results.Add(glymaSecurityGroup, response); } catch (Exception ex) { result.HasError = true; result.ErrorMessage = ex.Message; } } if (!result.HasError) { securityAssociations.HasAssociations = results; securityAssociations.IsInherited = isInherited; result.Result = securityAssociations; } } else { result.HasError = true; result.ErrorMessage = "Access Denied. User does not have permissions to access this web service method."; } return(result); }
public void Load(SecurityAssociations data, bool isInherited) { IsInherited = isInherited;//!data.IsInherited; foreach (var valuePair in data.HasAssociations) { foreach (var permissionGroup in PermissionGroups) { var found = permissionGroup.FirstOrDefault(q => q.Id == valuePair.Key.GroupId); if (found != null) { found.ResetValue(valuePair.Value); found.IsEnabled = !isInherited;//!data.IsInherited; } } } IsLoaded = true; if (LoadCompleted != null) { LoadCompleted(this, null); } }