Question

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!

Was it helpful?

Solution 2

You can get userid from context. Recheck this article.

OTHER TIPS

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;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top