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

  • gordonj Profile Picture
    gordonj 255 on at
    RE: Connection String does not seem to work for AD / O365 Integration

    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.

  • Stuie Profile Picture
    Stuie 255 on at
    RE: Connection String does not seem to work for AD / O365 Integration

    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
    gordonj 255 on at
    RE: Connection String does not seem to work for AD / O365 Integration

    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.

  • Verified answer
    Kokulan Profile Picture
    Kokulan 18,052 on at
    RE: Connection String does not seem to work for AD / O365 Integration

    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
    gordonj 255 on at
    RE: Connection String does not seem to work for AD / O365 Integration

    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
    Kokulan 18,052 on at
    RE: Connection String does not seem to work for AD / O365 Integration

    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
    gordonj 255 on at
    RE: Connection String does not seem to work for AD / O365 Integration

    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;"

  • Kokulan Profile Picture
    Kokulan 18,052 on at
    RE: Connection String does not seem to work for AD / O365 Integration

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

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans