Integrating and retrieving data from a Microsoft CRM 2013 instance is a common request, and I have found myself working on a number of these solutions lately. I encountered a recent example where a client was using an Internet Facing Deployment of CRM 2013.
In this case, I needed to connect to the Microsoft CRM 2013 server to retrieve data to be integrated into Dynamics GP.
Here is a quick sample of code you may use to connect to an internet facing deployment of Microsoft CRM 2013 using claims based authentication.
// Get the endpoint of the CRM organization service.
Uri organizationServiceUri = new Uri(@"CrmOrganizationServiceEndpointUri"); // In production code, abstract this to configuration.
// Get the service configuration.
IServiceConfiguration<IOrganizationService> serviceConfiguration = ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>(organizationServiceUri);
// Set up the credentials.
ClientCredentials clientCredentials = new ClientCredentials();
clientCredentials.UserName.UserName = "CrmUserName"; // In production code, abstract this to configuration.
clientCredentials.UserName.Password = "CrmPassword"; // In production code, abstract this to configuration.
using (OrganizationServiceProxy organizationServiceProxy = new OrganizationServiceProxy(serviceConfiguration, clientCredentials))
// Perform business logic here.
This blog has been relocated from http://mbsguru.blogspot.com/ with authorization.