private PowerShellResults <AdminRoleGroupRow> RemoveRoleAssignments(IEnumerable <Identity> removedRoles, ManagementRoleAssignments roleAssignmentsWebService, Identity identity, PowerShellResults <AdminRoleGroupRow> results) { if (removedRoles != null) { foreach (Identity roleIdentity in removedRoles) { PowerShellResults <ManagementRoleAssignment> roleAssignments = this.GetRoleAssignments(roleIdentity, identity, roleAssignmentsWebService); if (roleAssignments.Failed) { results.MergeErrors <ManagementRoleAssignment>(roleAssignments); return(results); } if (roleAssignments != null && roleAssignments.Output != null) { ManagementRoleAssignment[] output = roleAssignments.Output; IEnumerable <Identity> source = from entry in output where entry.DelegationType == RoleAssignmentDelegationType.Regular select entry.Identity; results.MergeErrors(roleAssignmentsWebService.RemoveObjects(source.ToArray <Identity>(), null)); if (results.Failed) { return(results); } } } return(results); } return(results); }
private PowerShellResults RemoveRoleAssignments(List <Identity> roles, RoleAssignmentPolicy policy, ManagementRoleAssignments service) { PowerShellResults <ManagementRoleAssignment> list = service.GetList(new ManagementRoleAssignmentFilter { RoleAssignee = policy.Identity }, null); if (list.Failed) { return(list); } List <Identity> list2 = new List <Identity>(); foreach (ManagementRoleAssignment managementRoleAssignment in list.Output) { if (roles.Contains(managementRoleAssignment.Role.ToIdentity())) { list2.Add(managementRoleAssignment.Identity); } } return(service.RemoveObjects(list2.ToArray(), null)); }