public static List<Entity> RetrieveRolePrivileges(Guid securityRoleId)
{
var roleRequest = new RetrieveRolePrivilegesRoleRequest { RoleId = securityRoleId };
RetrieveRolePrivilegesRoleResponse roleReponse = new RetrieveRolePrivilegesRoleResponse();
roleReponse = (RetrieveRolePrivilegesRoleResponse)service.Execute(roleRequest);
var privilegeQuery = new QueryExpression { EntityName = "privilege", ColumnSet = new ColumnSet(true) };
var filter = new FilterExpression(LogicalOperator.Or);
List<Guid> prvIdCollecyion = new List<Guid>();
foreach (var p in roleReponse.RolePrivileges)
{
prvIdCollecyion.Add(p.PrivilegeId);
}
filter.AddCondition("privilegeid", ConditionOperator.In, prvIdCollecyion.Cast<object>().ToArray());
privilegeQuery.Criteria = filter;
List<Entity> contactPrivileges = new List<Entity>();
EntityCollection privileges = service.RetrieveMultiple(privilegeQuery);
contactPrivileges = privileges.Entities.ToList()
.Where(p => p.GetAttributeValue<String>("name").ToLower()
.Contains("contact")).ToList();
return contactPrivileges;
}