Connect to Multi-factor Enabled D365 CDS Programmatically (Online 9.1)

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 here.

Note: 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.

Also, nowadays more and more organizations are focusing towards security and hence they have enabled Multi-factor Authentication.

In all, there is a need to connect to D365 CDS using a more robust and latest way. We will use capabilities of Azure Active Directory here.

Step 1 : Get Application ID and Client Secret Key using Azure Active Directory

  • Connect to Azure Admin Portal
    Login to https://portal.azure.com
    Click on Azure Admin Directory
    Click on App Registrations
    Click on New registration
  • Give an appropriate name of your app which is going to connect to D365 CDS programmatically. Click Register.
    Copy generated Application ID
Trial Application
Trial Application
  • Now click on Certificates and Secrets for your app.
    Click on ‘New Client Secret’, add description and expiry details.
    Once added, copy ‘Client Secret Key Value’.

Step 2 : Add Application User in D365 CDS Environment

  • Login to D365 CDS environment.
  • Go to Settings –> Security –>Users.
  • Change the view to ‘Application Users’ and click New. Make sure the form is ‘Application User’ form.
  • Add details and Application Id generated in step 1 above.
  • Assign appropriate Security role to this Application User as per your organization’s security set up.

Step 3: Add connection string in your c# code as follows:

Format
String connectionString = “AuthType=ClientSecret; url=<your organization URL>; ClientId=<your application id>; ClientSecret=<client secret key>”;

Example
string connectionString = “AuthType=ClientSecret; url=https://cdsinctrial.crm.dynamics.com/main.aspx; ClientId=40c95818-9306-437a-85c1-0db96ba277ae; ClientSecret=~s5~KXUMoT-L5dFXg21IutB18-EsD0hoi-“;

Code Snippet: (Change values as per your organization set up values)

References:
https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/authenticate-office365-deprecation


Hope this helps to achieve your goal. Please share your comments.

Like this article?

Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Pinterest

Let Nemely  keep you updated!

Questions, comments, or suggestions? Contact us, and we’ll get back to you as soon as possible.

Related Posts

Webinar: Work More Efficiently with Copilot and AI in Microsoft Dynamics

Webinar: Work More Efficiently with Copilot and AI in Microsoft Dynamics

In the rapidly evolving world of technology, artificial intelligence (AI) continues to play a significant role in…
Connect to Multi-factor Enabled D365 Dataverse/CDS Programmatically Using Certificates (Online 9.1)

Connect to Multi-factor Enabled D365 Dataverse/CDS Programmatically Using Certificates (Online 9.1)

As the continuation to my earlier blog post, “Connect MFA Enabled D365 CDS Programamatically”, where we connected…
Generate PDF Report in Dynamics CRM 365

Generate PDF Report in Dynamics CRM 365

There is plenty of material available to achieve this very commonly needed functionality to generate PDF of…

Read More About Our Products

crm alerts hero
AppIcon_Colorful
CRM Alerts
The ultimate companion app for your mobile CRM users. CRM Alerts simplifies the work life for any CRM user that is doing sales-related activities with their mobile devices on a regular basis
shutterstock_710149132
Access Templates Icon 2
Access Templates
User security role and team assignment solution. Do you have a complex security model in your CRM system and having difficulty keeping track of which security roles and teams to assign to different user types? We have a solution for you!
NemelyProspectingHero
NemelyProspecting
Nemely Prospecting
Get relevant and up-to-date company information. With Nemely Prospecting, you can easily find and import company information directly from within your CRM.
Product Lifecycle Management
PLM Icon
Product Lifecycle
Asset and contract management. Manage customer assets and related contracts in Dynamics CRM. It's a plug-and-play solution, completely customizable, uses latest technology, works on all devices, and more.
shutterstock_1233205321
Sharepoint Extended
Sharepoint Extended
Enhanced document management. Built on top of the native integration between Microsoft Dynamics and Sharepoint, our solution Sharepoint Extended extends the functionality with better user experience, default structures, and document template creation.
Nemely Essentials
Nemely Essentials Inverted
Nemely Essentials
Dynamics CRM for small businesses. With the power of Dynamics 365 under the hood, but with a clean and simplified user experience with clever time-saving functionalities, you really get the best of both worlds.
Legal Practice Management
Legal Icon
Legal Practice Management
Client Relationship Management for law firms. Our packaged solution for law firms, built on top of Microsoft Dynamics 365 and Project Operations, combines several processes related to the acquiring, compliance validation, onboarding, delivery, and invoicing of legal services.