|
When writing code to interface with CRM using the WebService interface it is often necessary to find out details about the user that is being used to login to the interface. This simple function will return a structure with some information about the current user, the most important and useful is the Guid representing the UserId.
public static WhoAmIResponse GetcurrentUser(CrmService crm) { WhoAmIRequest request = new WhoAmIRequest(); WhoAmIResponse user = (WhoAmIResponse)crm.Execute(request); return user; }
This takes the CrmService obtained when you connect to the WebService and the Guid representing the currently logged in user can be obtained by using the function:
Guid UserId = GetcurrentUser(crm).UserId;
|
01 December 2009 IB
Microsoft Dynamics CRM
|
Back To List
Did this article answer your question |
 |
Yes |
 |
No |
|
Other items of interest in our knowledgebase
|