Skip to main content

Notifications

Announcements

No record found.

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;

}
}

  • Suggested answer
    sdfasdf Profile Picture
    sdfasdf 840 on at
    RE: User Authentication Failed when connecting to CRM2013 from C# application

    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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans