Get Id of user currently logged into MS Dynamics CRM 2011 Online

巧了我就是萌 提交于 2019-12-11 13:47:09

问题


Is there a way to retrieve/identify the user that is currently logged into MS Dynamics CRM 2011 Online?

What i'm trying to accomplish here is kind of like the facebook login except with MS Dynamics. I need to somehow detect whether the user has logged into the MS Dynamics website. If the user is logged into the MS Dynamics website, i'll have to grab the UserId and authenticate it with Kentico CMS.

I've tried messing with the WhoAmIRequest, but unfortunately it needs a credential to properly execute.

Any help would be great!


回答1:


You can get userid from context. Recheck this article.




回答2:


You can get the Currently Logged in User Id by

 WhoAmIRequest request = new WhoAmIRequest();
            WhoAmIResponse response = (WhoAmIResponse)Service.Execute(request);
            if (response != null)
                return response.UserId;

You can create a default service like:

ClientCredentials Credentials = new ClientCredentials();
Credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
//This URL needs to be updated to match the servername and Organization for the environment.


Uri OrganizationUri = new Uri("http://crm/XRMServices/2011/Organization.svc");

Uri HomeRealmUri = null;

//OrganizationServiceProxy serviceProxy; 

OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, null)

IOrganizationService service = (IOrganizationService)serviceProxy;


来源:https://stackoverflow.com/questions/21393922/get-id-of-user-currently-logged-into-ms-dynamics-crm-2011-online

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!