Search code examples
.netdynamics-crmdynamics-crm-4

Microsoft Dynamics 4.0 Custom ASPX Page Identity


What is the recommended approach for obtaining the identity of the currently logged in MS Dynamics user from code behind for a custom ASPX page that lives in the ISV directory?

The approach for doing this must be agnostic of whether Dynamics is using AD/NTLM authentication or other authentication mechanisms and must not require enabling impersonation or changing the web.config.

Thanks


Solution

  • You can get the systemuserid from the CRM database by executing a WhoAmIRequest through the CRM web service and then get the systemuser record via crmservice.Retrieve(). As long as the user has any CRM security roles assigned at all, WhoAmIRequest and read access to their own systemuser record should always work.