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.
}
No comments:
Post a Comment