Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

retrieve all privileges for security role

(1) ShareShare
ReportReport
Posted on by

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;
}

  • Amar Singh MSFT Profile Picture
    on at
    RE: retrieve all privileges for security role

    Is there any simpler way then this?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 106

#3
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 82 Super User 2025 Season 1

Overall leaderboard

Product updates

Dynamics 365 release plans