web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Connection String does not seem to work for AD / O365 Integration

(0) ShareShare
ReportReport
Posted on by 255

I have been using the XRM Tooling assembly for integration applications for some time.

Our company is currently on CRM 2016 but we have built a brand new Dynamics 365 instance and are ready to make the transition.

We have "AD integrated with O365" so use our domain credentials to login to Dynamics 365.

I have been testing a command line app and have found that the Connection String method from XRM Tooling works fine when the type is set to AD and I supply the Dynamics URL.

However, if I try to supply an AD Account directly using any combination of username, password and domain, I cannot connect.

Is this broken?

I have been advised by someone who had a similar issue that the workaround is to create a dedicated O365 account and use that.  However this has a licencing cost and we already have a service account in place that I would rather use. 

*This post is locked for comments

I have the same question (0)
  • Kokulan Profile Picture
    18,054 on at

    Are you using CrmServiceClient or different approach to connect to CRM? Could you please share the connection code?

  • gordonj Profile Picture
    255 on at

    Apologies, I should have said that yet I am using "CrmServiceClient".

    This works: "Url=mycrm.crm11.dynamics.com; AuthType=AD;"

    This does not work: "Url=mycrm.crm11.dynamics.com; AuthType=AD; Domain=mydomain; Username=username; Password=password;"

  • Verified answer
    Kokulan Profile Picture
    18,054 on at

    Since your AD synced to O365, the it should authenticate with 365 method, could you try the following code and see if this works for you

    CrmServiceClient SourceCRM = new CrmServiceClient(

    "username",
    CrmServiceClient.MakeSecureString("password"),
    "", "Org Unique ID - you can get it from Settings -> Customization -> Developer Resources page",
    useUniqueInstance: true,
    useSsl: true, isOffice365: true);

    Make sure you use the latest CRM SDK DLLs.  If you are connecting from Console App you may have to add the following line before you actually connect

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

     

    https://github.com/Kokulan365/CRMServiceClientQuickStart/blob/master/KED365.CrmServiceClient.QuickStart/Program.cs

  • gordonj Profile Picture
    255 on at

    Aha, that does work.  So it is the case that the Connection String does not work in this instance.

    I usually put that in the App.Config as one value.  I guess with the version above, I need to split out the username, password etc as separate settings.

  • Verified answer
    Kokulan Profile Picture
    18,054 on at

    You could still use the connection string, have you tried the following with the above code

    <connectionStrings>  

       <!-- Online using Office 365 -->  

       <!-- <add name="ConnStringName"  

            connectionString="Url=contoso.crm.dynamics.com; Username=someone@contoso.onmicrosoft.com; Password=password; authtype=Office365"/> -->  

     </connectionStrings>  

  • gordonj Profile Picture
    255 on at

    Thank you for all the answers.  There is the alternative method above and the connection string which is an answer.

    My issue was moving from AD to Office365, I discovered that we has a second set of O365 logins on our domain which I had not expected.  We have "@domain.com" but also "servicedomain.com".  It was only when I looked more closely at the User in CRM did I spot the difference.

    I can confirm that, in my situation AD/O365 integration is now working with the standard connection string.

  • Stuie Profile Picture
    255 on at

    Hi

    I'm having issues connecting to CRM from a webservice. It was fine a couple of days ago.

    My conn string is

                        string conn = "AuthType=Office365;Url=https://************.api.crm4.dynamics.com/XRMServices/2011/Organization.svc;Username=stuart@****.com;Password=***";

    A console app fails too

    using System;

    using System.Net;

    using Microsoft.Xrm.Tooling.Connector;

    namespace WorkWithCsharp

    {

       class Program

       {

           static void Main(string[] args)

           {

               try

                    {

                        string conn = "AuthType=Office365;Url=****.api.crm4.dynamics.com/.../Organization.svc;Username=stuart@****.com;Password=***";                       ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

                        CrmServiceClient crmServiceClient = new CrmServiceClient(conn);

                        if (crmServiceClient.IsReady)

                        {

                            Console.WriteLine("\nConnection successful.");

                        }

                        else

                        {

                            Console.WriteLine("\nPlease make sure the Connection String is correct.");

                            Console.WriteLine(crmServiceClient.LastCrmException.ToString());

                        }

               }

               catch (Exception ex)

                {

                    throw new Exception(ex.Message);

                }

           }

       }

    }

  • gordonj Profile Picture
    255 on at

    Update Nuget to latest stable assemblies. MS removed some old code from inside the Tooling assembly.

    That should fix it.

    You may find that XrmToolbox is now broken, if you use it. Same reason.  Update and use Ms login control rather than connection wizard.

    Hope that helps.

    Always possible you have another issue but the change happened a couple of days ago.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans