
I am not able to connect to CRM 2013 from C# application, getting user authentication failed, however the same code is working fine from another system which has SDK installed. Do we need to install SDK?
ClientCredentials credentials = new ClientCredentials();
credentials.Windows.ClientCredential = new System.Net.NetworkCredential("*******, "******", "domain");
using (var serviceProxy = new OrganizationServiceProxy(new Uri(SoapOrgServiceUri), null, credentials, null))
{
serviceProxy.Authenticate();
_service = (IOrganizationService)serviceProxy;
}
}
Hi,
The recommended way to connect to CRM using SDK is by using a connection string with the CrmServiceClient class. Here's a useful article that describes how to use this approach: docs.microsoft.com/.../use-connection-strings-xrm-tooling-connect
I would also recommend you to use NuGet to download the SDK assemblies for CRM 2013 (version 6.*)
As far your scenario, I think this would be the code you might want to experiment with:
var connectionString = "AuthType=AD; Url=http://server:5555/OrgName; Username=user; Password=pwd; Domain=domain";
using (var client = new CrmServiceClient(connectionString))
{
if (!client.IsReady)
{
throw new ApplicationException("Unable to connect to CRM. Please check your connection string.");
}
var organizationService = (IOrganizationService)client;
// work with organizationService
}
If that does not work, then my recommendation is to start troubleshooting the error message you get. Please feel free to share the error message if this approach doesn't work for you.
I hope it helps!