In brief

Connection examples and their original scope.

  • This 2020 guide covers C# connection strings for Dynamics 365 on-premises and the non-MFA CDS online scenario.
  • The original article includes Microsoft’s notice that WS-Trust authentication was deprecated for CDS client connections.
  • Use the linked Microsoft guidance to assess authentication for a new project.

Originally published in 2020. This walkthrough retains the interfaces and libraries used at the time. For a new project, start with Microsoft’s current Dataverse authentication guidance.

As a developer, I regularly connect to Dynamics 365 on-premises and D365 CDS online using C#. Below are the connection-string approaches covered in this archived guide.

  • D365 CDS Online (Non-MFA)

Related resource

Code example 1

Open the original code example in a new tab.
Open resource

Microsoft deprecated WS-Trust authentication for Common Data Service client connections; see the announcement. This change concerns client connections, rather than custom plug-ins, workflow activities or on-premises/IFD service connections.

Please check my blog post, “Connect to Multi-factor Enabled D365 CDS Programmatically” for more details.

  • D365 CE (On-Premise) Method 1

Related resource

Code example 2

Open the original code example in a new tab.
Open resource

Method 2: On-premises without IFD

Related resource

Code example 3

Open the original code example in a new tab.
Open resource

Hope this helps to achieve your goal.