Monday 8 June 2015

How to get IOrganizationService Object of CRM Online using C#

Hi,

Here is the code to get the IOrganizationService Object of CRM online using C#


public static IOrganizationService GetOrganizationService(string strUserName, string strPassword, string strServiceURL)
{
       ClientCredentials userCredentials = new ClientCredentials();
       userCredentials.UserName.UserName = strUserName;
       userCredentials.UserName.Password = strPassword;
       var orgService = new OrganizationServiceProxy(new Uri(strServiceURL + "/XRMServices/2011/Organization.svc"), null, userCredentials, null);
       orgService.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
       return orgService;
}

Hope this helps.

--
Happy CRM'ing
Gopinath.

No comments:

Post a Comment