Search code examples
c#dynamics-crm-2011dynamics-crm-2013fetchxml

How to query privileges specific to entity (without the ID of the entity record) using CRM 2011/2013 sdk?


Creating an external MVC website using CRM 2011/2013 web services. Must hide/show parts of the application based on write access to a certain custom entity. Found solutions like

http://mileyja.blogspot.de/2011/05/using-retrieveuserprivileges-requests.html

Here the RetrieveUserPrivilegesRequest requires the systemuser id and the entity record id as parameters. Workarounds on the subject use .First() to get a record and retrieve the privileges. The solution is not convincing because of the possibility of the absence of records.

The other solutions as RetrieveUserPrivilegesRequest returns Guid-s of privileges. These can change from CRM instance to instance. Also roles get things complicated. Does anyone knowif there exists a straight forward way to verify if the system user has write access to a certain entity?


Solution

  • This requirement can be fulfilled by a combination of a QueryExpression and a RetrieveUserPrivilegesRequest or by a single QueryExpression.

    Check if a User has a specific Privilege