Recently I was exploring about setting Multi Factor authentication for my Dynamics 365 Instance and connecting to it via code using Console applications. This is when I came know about using an App password for my Console application to work.
But do you know that based on the user states, MFA setup behaves differently..
Ok..now let’s take a simple console application which just does nothing but connects using a OrganizationServiceProxy. Sample code can be found here.
- When MFA is disabled, you will be able to connect to the instance without any issues.
2. Now Enable the MFA but don’t enforce it. Don’t sign in and complete the registration process of either providing pin or answering the call. Try to run the same console code above, you would be still able to connect without any issues.
This is because Console application would also behave as non browser app. and will continue to work until the sign up is done exclusively as stated in the table above.
3. After the multifactor authentication is enforced, users will need to create app passwords for working with non browser applications. So now if you try to run the same Console application, you would get an error..
Now sign in to your instance and generate the app password by providing additional security information when signing up. Use the same app password in place of credentials used while connecting to CRM in the console app.
And now you will be able to connect without issues…
Hope this helps..
PMDY.