RetrievePrincipalAccessRequest is used to determine a Principal's access to a specific entity
instance, not an entity. As such, you must pass a GUID for an existing entity instance in the EntityReference specified as the Target. E.g.:
Guid contactId =
(
from c in xrm.ContactSet
where c.FirstName.StartsWith("A")
select c.Id
).Take(1).First();
if (userId != null)
{
RetrievePrincipalAccessRequest req = new RetrievePrincipalAccessRequest();
//specify team or systemuser you want to get privileges for
req.Principal = new EntityReference("systemuser", userId.Value);
//specify the CRM record you want to check principal permissions for (can be any entity type)
req.Target = new EntityReference("contact", contactId);
RetrievePrincipalAccessResponse resp = (RetrievePrincipalAccessResponse)context.Execute(req);
}
--pogo (pat) @ pogo69.wordpress.com