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
You can get the
systemuserid
from the CRM database by executing a WhoAmIRequest through the CRM web service and then get thesystemuser
record viacrmservice.Retrieve()
. As long as the user has any CRM security roles assigned at all,WhoAmIRequest
and read access to their ownsystemuser
record should always work.