Notifications
Announcements
No record found.
Hello Experts,
I'm trying to connect to dynamics 365 CRM instance through console application but getting 'Unable to login to CRM' error.
Here is my code.
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; string connectionString = "AuthType=ClientSecret; url=myorg.crm.dynamics.com; ClientId=b77e2b5a-3946-485e-########; ClientSecret=s.tOrEuew_QTuGxV8Y0v4iTK######; CrmServiceClient crmServiceClient = new CrmServiceClient(connectionString); if (crmServiceClient != null && crmServiceClient.IsReady) { Console.WriteLine("\nConnection successful."); }
I performed all the steps mentioned in this link:
https://nemely.com/blog/connect-to-multi-factor-enabled-d365-cds-programmatically-online-9-1/
Thanks,
Priyank
Hello Priyank
You are using WS Trust authentication and that's deprecated.
docs.microsoft.com/.../authenticate-office365-deprecation
Try to go with this sample instead:
docs.microsoft.com/.../sample-simplified-connection-quick-start
Or you can download the whole sample here:
github.com/.../QuickStartCS
Hi
for any body who is struggling to connect old Console Application code with MFA Enabled CRM
To Connect MFA Enabled Dynamics CRM with C# you just need to use App Password instead of your Password remaining every thing remains same as it was
string connectionString = GetServiceConfigurationfromAppCOnfig();
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
CrmServiceClient conn = new Microsoft.Xrm.Tooling.Connector.CrmServiceClient(connectionString);
_orgService = (IOrganizationService)conn.OrganizationWebProxyClient != null ? (IOrganizationService)conn.OrganizationWebProxyClient : (IOrganizationService)conn.OrganizationServiceProxy;
WhoAmIResponse whoAmIResponse = (WhoAmIResponse)_orgService.Execute(new WhoAmIRequest());
Follow the Steps to generate App password
community.dynamics.com/.../connecting-to-mfa-enabled-dynamics-365-v9-x-crm-instance-through-c-or-console-app
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Tom_Gioielli 170 Super User 2025 Season 2
#ManoVerse 61
Gerardo RenterÃa Ga... 52 Most Valuable Professional