locked
configuring CRM in c# application for IFD RRS feed

  • 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

  • Make sure you're using the DLL's from the latest CRM SDK.

    If my response helped you find your answer please show your thanks by taking the time to "Mark As Answer" and "Vote As Helpful".

    Twitter LinkedIn Facebook Blog Magnetism

    Thursday, September 26, 2013 8:43 AM
  • 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 AM
    Moderator
  • 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