web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

User Authentication Failed when connecting to CRM2013 from C# application

(0) ShareShare
ReportReport
Posted on by 5

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;

}
}

I have the same question (0)
  • Suggested answer
    sdfasdf Profile Picture
    842 on at

    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!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 72 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 29 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans