WhoAmI Message (CrmService)
![]() |
[Applies to: Microsoft Dynamics CRM 4.0]
Find the latest SDK documentation: CRM 2015 SDK
| Works for all deployment types | Works online and offline |
Retrieve the system user entity instance for the currently logged on user or the user under whose context the executed code is running.
The relevant classes are specified in the following table.
| Type | Class |
| Request | WhoAmIRequest |
| Response | WhoAmIResponse |
Remarks
To use this message, pass an instance of the WhoAmIRequest class as the request parameter in the Execute method.
For a list of required privileges, see WhoAmI Privileges.
Example
The following code example shows how to use the WhoAmI message.
[C#]
// Set up the CRM service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0;
token.OrganizationName = "AdventureWorksCycle";
CrmService service = new CrmService();
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;
// Create the request object.
WhoAmIRequest userRequest = new WhoAmIRequest();
// Execute the request.
WhoAmIResponse user = (WhoAmIResponse) service.Execute(userRequest);
[Visual Basic .NET]
' Set up the CRM service.
Dim token As New CrmAuthenticationToken()
' You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0
token.OrganizationName = "AdventureWorksCycle";
Dim service As New CrmService()
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials
' Create the request object.
Dim userRequest As New WhoAmIRequest()
' Execute the request.
Dim user As WhoAmIResponse = CType(service.Execute(userRequest), WhoAmIResponse)
See Also
Concepts
Reference
.gif)