Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 55831

Retrieve all Accounts if a users has Read Access to them using C#

$
0
0

I am at on-prem environment of Dynamics CRM 2011, I want to enlist all those accounts to whom a user have read access. So far, I am just reach out to the following but it is by just checking if the user have ReadAcces. But I want to query once and populate all those accounts the user have read access.

private static bool retrieveReadAccess(IOrganizationService service, Guid userId, Guid avcId)
        {
            //retrieve user ReadAccess to account
            RetrievePrincipalAccessRequest principalAccessReq = new RetrievePrincipalAccessRequest
            {
                Principal = new EntityReference("systemuser", userId),
                Target = new EntityReference("account", avcId)
            };
            RetrievePrincipalAccessResponse principalAccessRes = (RetrievePrincipalAccessResponse)service.Execute(principalAccessReq);

            if (principalAccessRes.AccessRights.HasFlag(AccessRights.ReadAccess))
            {
                return true;
            }
            return false;
        }



Viewing all articles
Browse latest Browse all 55831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>