I am using Dynamics 365 v9 on-premise.
The Impersonation successfully worked in Plugin and workflow. In Plugin, I created the OrganizationService by var service = serviceFactory.CreateOrganizationService(null); And In workflow i did impersonation by setting OrganizationServiceProxy CallerId.
But, I also have external web application where i do Active Directory authentication, create CRM service and do rest of the data retrievals from the database.
Here after web authentication, I am creating CRM service, i am updating the CallerId of the proxy and creating Retrieve request for the secure fields data. Although I am updating the CallerId, its still not getting the data. I checked all the privileges for the user.
So, i tried the WEB API method. below code: systemuserguid is the systemuserid of SYSTEM user. This is my request and i get null for secure fields. User has no read privelages to the secure field. So, i am trying to impersonate and was able to excute plugin and workflow but not external web application authentication and then create crm service and update the CallerId. And try to get the secure field data.
Key is the secure field i am trying to access.
var options = "?$select=key,name";
var endpoint = Xrm.Utility.getGlobalContext().getClientUrl() + "/api/data/v9.0/accounts(guid)";
var uri = endpoint + options;
var request = new XMLHttpRequest();
request.open("GET", encodeURI(uri), false);
request.setRequestHeader("MSCRMCallerID", "systemuserguid");
request.setRequestHeader("OData-MaxVersion", "4.0");
request.setRequestHeader("OData-Version", "4.0");
request.setRequestHeader("Accept", "application/json");
request.setRequestHeader("Content-Type", "application/json; charset=utf-8");
Please anyone can help me why MSCRMCallerID not working in this case.
Thank you.