I am trying to develop a C# WPF application that will update records in CRM. I want the application to automatically authenticate based on the currently logged in users domain credentials.
I have read a few tutorials that provide the following code:
Uri prodOrgUri = new Uri("https://crm.domain.com:<port>/<org>/XRMServices/2011/Organization.svc");
Uri homeRealmUri = null;
ClientCredentials credentials = new ClientCredentials();
credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
using (OrganizationServiceProxy _Service = new OrganizationServiceProxy(prodOrgUri, homeRealmUri, credentials, null))
{
_Service.EnableProxyTypes();
IOrganizationService _iOrganizationService = (IOrganizationService)_Service;
var context = new XrmServiceContext(_iOrganizationService);
// CRM code
}
However this always fails to authenticate. I have no problem connecting via this method when I manually define the login credentials, it is only when trying to automatically authenticate the user.
Debugging the code shows that the ClientCredential object has blank values for domain, username and password.
Any help in this matter would be much appreciated. Not having the user typing in their login credentials is an integral part of this application.
Thanks in advance,
Daniel Di Giandomenico