As a developer, I regularly create connection to my D365 instance (On-Premise) and/or D365 CDS online(MFA and non-MFA) programmatically using c#. I will list down how you can create connection strings for the same below.
- D365 CDS Online (Non-MFA)
Note: As per Microsoft announcement, Use of the WS-Trust authentication security protocol when connecting to Common Data Service is no longer recommended and has been deprecated; see the announcement.
This change only impacts client applications that connect to the Common Data Service. It does not impact 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
Method 2 (On-Premise without IFD)
Hope this helps to achieve your goal. Please share your comments.