Answered by:
configuring CRM in c# application for IFD

Question
-
Hi,
I have developed a c# windows application that connects with CRM to update some entities. When tested on premise, the application worked successfully, however when I deployed it at the actual live server for IFD it gives me a Sytem.InvalidOperationException: The user authentiction failed.
Connection with CRM is done via the configuration file, and I am sure that the credentials are correct.
<add name="Xrm" connectionString="Authentication Type=AD; Server=https://mycompany.mycompany.com:portnumber/; Domain=mydomain; Username=myusername; Password=mypassword" />
Does anyone have any idea what the problem is?
Many Thanks!
Thursday, September 26, 2013 7:51 AM
Answers
-
Hi guys,
thanks a lot for your replies.
I managed to solve this by removing the 'Domain' key value pair from the connection string in the config file, and instead included it in the username; i.e.
FROM
<add name="Xrm" connectionString="Authentication Type=AD; Server=https://mycompany.mycompany.com:portnumber/; Domain=mydomain; Username=myusername; Password=mypassword" />
TO
<add name="Xrm" connectionString="Server=https://mycompany.mycompany.com:portnumber/; Username=mydomain\myusername; Password=mypassword" />
Thanks again!
- Marked as answer by mikevmalta Friday, September 27, 2013 1:34 PM
Friday, September 27, 2013 1:33 PM
All replies
-
-
How are you passing the credentials to CRM - i.e. what is the code that you use to instantiate and set the properties of the IOrganizationSerice (or a derived class) instance ?
And are you using the sdk assemblies, or a service reference to connec to CRM ?
Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk
Thursday, September 26, 2013 9:19 AMModerator -
If you are using the SDK assembly, this should do it:
Uri serviceUrl = new System.Uri(string.Format("{0}{1}", ServerUrl, SERVICE_PATH)); ClientCredentials credentials = new ClientCredentials(); credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials; credentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; if (!string.IsNullOrEmpty(UserLogin)) { credentials.UserName.UserName = this.UserLogin; credentials.UserName.Password = this.UserPassword; } service = new OrganizationServiceProxy(serviceUrl, null, credentials, null);
Salim Adamon - http://thedynamicscrmblog.wordpress.com/
Thursday, September 26, 2013 9:38 AM -
Connection Method for CRM 2011 IFD.
string ServerUrl = string.Format("{0}/XRMServices/2011/Organization.svc", "https://crm2011.hosted.com"); ClientCredentials credentials = new ClientCredentials(); credentials.UserName.UserName = "UserName"; credentials.UserName.Password = "P4$$w0rd"; IServiceManagement<IOrganizationService> orgServiceManagement = ServiceConfigurationFactory.CreateManagement<IOrganizationService>(new Uri(ServerUrl)); AuthenticationCredentials authCredentials = new AuthenticationCredentials(); authCredentials.ClientCredentials = credentials; AuthenticationCredentials tokenCredentials = orgServiceManagement.Authenticate(authCredentials); OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(orgServiceManagement, tokenCredentials.SecurityTokenResponse);
Thursday, September 26, 2013 12:59 PM -
Hi guys,
thanks a lot for your replies.
I managed to solve this by removing the 'Domain' key value pair from the connection string in the config file, and instead included it in the username; i.e.
FROM
<add name="Xrm" connectionString="Authentication Type=AD; Server=https://mycompany.mycompany.com:portnumber/; Domain=mydomain; Username=myusername; Password=mypassword" />
TO
<add name="Xrm" connectionString="Server=https://mycompany.mycompany.com:portnumber/; Username=mydomain\myusername; Password=mypassword" />
Thanks again!
- Marked as answer by mikevmalta Friday, September 27, 2013 1:34 PM
Friday, September 27, 2013 1:33 PM