Thursday, 15 April 2021

Connect Dynamic CRM 365 using console with Mutli Factor Authentication

Get Client Id and Secret from APP registration in azure portal    

  string connectionString = "AuthType=ClientSecret; url=https://org55ced39c.crm.dynamics.com/;ClientId=ClientID ClientSecret=Secret";


            CrmServiceClient crmServiceClient = new CrmServiceClient(connectionString); //Connecting to the D-365 CE instance


            if (crmServiceClient != null && crmServiceClient.IsReady)


            {

                OrganizationServiceContext orgContext = new OrganizationServiceContext(crmServiceClient);


               var contact = from c in orgContext.CreateQuery("contact")

                             select c;


                Console.ForegroundColor = ConsoleColor.Green;


                Console.WriteLine("\nConnected Successfully!");


No comments:

Post a Comment