Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Enable D365 Multifactor authentication programmaticaly

(0) ShareShare
ReportReport
Posted on by 834

I am using below block to get into D365 from outside, my Dynamics now using MWF due to which login is getting blocked. My client want this MWF enabled. 

https://nemely.com/blog/connect-to-multi-factor-enabled-d365-cds-programmatically-online-9-1/

I am not getting error just connection i Can't establish

Anyone has tried this any ideas?

  • Suggested answer
    Bipin D365 Profile Picture
    28,981 Moderator on at
    RE: Enable D365 Multifactor authentication programmaticaly

    Hi,

    Have you checked the error details in crmServiceClient .CrmException and crmServiceClient .LastCrmException property?

    I hope you have assigned appropriate security roles and added Dynamics CRM Impersonation under API Permission in Azure app registration.

    Also, Modify the service url suggested by guido - docs.microsoft.com/.../use-connection-strings-xrm-tooling-connect

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Suggested answer
    Guido Preite Profile Picture
    54,082 Moderator on at
    RE: Enable D365 Multifactor authentication programmaticaly

    the code posted there is correct, the only thing I would change is the url, should be without /main.aspx, so something like

    Url=cdsinctrial.crm.dynamics.com;

    for creating the clientid/clientsecret, follow the first part of this blog post, is the most recent and contains useful screenshots:

    https://benediktbergmann.eu/2022/01/04/setup-a-service-principal-in-power-automate/

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Adis Profile Picture

Adis 136 Super User 2025 Season 1

#2
Sohail Ahmed Profile Picture

Sohail Ahmed 81

#3
Jonas "Jones" Melgaard Profile Picture

Jonas "Jones" Melgaard 77 Super User 2025 Season 1

Product updates

Dynamics 365 release plans