Monday, January 23, 2012

How to get access privilages for a user on a particular record

            RetrievePrincipalAccessRequest req = new RetrievePrincipalAccessRequest();

            //specify team or systemuser you want to get privileges for
            req.Principal = new EntityReference("team", teamId);

            //specify the CRM record you want to check principal permissions for (can be any entity type)
            req.Target = new EntityReference("account", accountid);

            RetrievePrincipalAccessResponse resp = (RetrievePrincipalAccessResponse)service.Execute(req);
            return resp.AccessRights.ToString();