Friday, 12 August 2011

CRM Online : How to Authenticate and create Organization service


Here is the code to authenticate and create the Organization service for CRM online 2011.

References used to ClientCredentials using System.ServiceModel.Description

and the code is
Uri HomeRealmUri = null;
ClientCredentials devicecredentials = new ClientCredentials();
devicecredentials.UserName.UserName = "<>";
devicecredentials.UserName.Password = "<>";

ClientCredentials credentials = new ClientCredentials();
credentials.UserName.UserName = "<>";
credentials.UserName.Password = "<>";
Uri organizationUri = new Uri("<>");

OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(organizationUri, HomeRealmUri, credentials, devicecredentials)

Microsoft.Xrm.Sdk.IOrganizationService service = (Microsoft.Xrm.Sdk.IOrganizationService)serviceProxy;

Read my another blog on how to generate devicecredentials.

Hope this helps.


No comments: