Monday, 30 May 2016

Permissions of the User on a record - RetrievePrincipalAccessRequest in CRM 2001//2013/2015/2016


Hi,


Today we got a requirement what are the permissions of the user on a particular record. To fullfill this requirement, there is a SDK message called "RetrievePrincipalAccessRequest"


Here is the sample code of it.

RetrievePrincipalAccessRequest retrieveRequest = new RetrievePrincipalAccessRequest();
// record for which we want to check the access
retrieveRequest.Target = new EntityReference("opportunity", new Guid("A9F18D5F-6A08-E611-80DE-000D3AA03DA0"));
// User or Team entity Reference
retrieveRequest.Principal = new EntityReference("systemuser", new Guid("1C5A2AE8-AD00-E611-80DD-000D3AA03DA0"));
RetrievePrincipalAccessResponse retrieveResponse = (RetrievePrincipalAccessResponse)crmSerivce.Execute(retrieveRequest);


In the response we get the combination of all the rights either through sharing or his own security roles


Hope this helps.

--
Happy CRM'ing

Gopinath

No comments:

Post a Comment