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)

Dynamics crm xrm tooling - online federation

(0) ShareShare
ReportReport
Posted on by

Hi ,

I am trying to  create an object CrmServiceClient. using the XrmTooling  without success .

My enviroment is dync 365 online with fedeartion .

i can't find a connection string example for this type of deployment in the documentation .

https://msdn.microsoft.com/en-us/library/mt608573.aspx 

Can anyone please assist?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    There are two ways you can do it, using a Connection String or Application Settings

    In your web or app configuration file you will need to specify the following settings:

    For connection string:

     <connectionStrings>

    <add name="MyCRMServer" connectionString="AuthType=Office365;Username=jsmith@contoso.onmicrosoft.com; Password=passcode;Url=https://contoso.crm.dynamics.com&quot;/>

     </connectionStrings>

    For application settings:

     <appSettings>

       <add key="Password" value="MhdhU1kduj/PbUIalN7RKA=="/>

       <add key="UserName" value="webuser@domain.com"/>

       <add key="InternalUrl" value="xxx.crm.dynamics.com"/>

       <add key="OrgName" value="crmorgnamefromdeveloperresources"/>    

     </appSettings>

    The following code will show you how to use both:

                   CrmServiceClient conn;

                   if (!string.IsNullOrEmpty(connectionString))

                   {

                       string connection = ConfigurationManager.ConnectionStrings["MyCRMServer"].ConnectionString;

                       conn = new Microsoft.Xrm.Tooling.Connector.CrmServiceClient(connectionString);

                   }

                   else

                   {

                       string userName = ConfigurationManager.AppSettings["UserName"].ToString();

                       string CRM_PASSWORD = ConfigurationManager.AppSettings["Password"].ToString();

                       string internalUrl = ConfigurationManager.AppSettings["InternalUrl"].ToString();

                       string orgName = ConfigurationManager.AppSettings["OrgName"].ToString();

                       NetworkCredential creds = new NetworkCredential(userName, ConvertToSecureString(CRM_PASSWORD));

                       Microsoft.Xrm.Tooling.Connector.AuthenticationType authType = Microsoft.Xrm.Tooling.Connector.AuthenticationType.Office365;

                       conn = new Microsoft.Xrm.Tooling.Connector.CrmServiceClient(userName, ConvertToSecureString(CRM_PASSWORD), "NorthAmerica", orgName, isOffice365: true);

                   }

    // The following is the ConvertToSecureString function:

           private static System.Security.SecureString ConvertToSecureString(string password)

           {

               if (password == null)

                   throw new ArgumentNullException("missing pwd");

               var securePassword = new System.Security.SecureString();

               foreach (char c in password)

                   securePassword.AppendChar(c);

               securePassword.MakeReadOnly();

               return securePassword;

           }

  • ScottDurow Profile Picture
    21 on at

    If you are using Dynamics online and your AD is federated with Azure AD- then you simply need to use AuthType=Office365 in your connection string.

  • Community Member Profile Picture
    on at

    Hi ,

    Thank you for your reply. But this is not working for me .

    As in the link / documentation Office365 is permitted for Dynamics 365 (online) instances only.  But it dosen't work for me when AD is federated .

    if i try to create OrganizationServiceProxy and supply  Client Credential with AuthenticationProvider as  OnlineFederation  it works.

    public OrganizationServiceProxy(

    Uri uri,

    Uri homeRealmUri,

    ClientCredentials clientCredentials,

    ClientCredentials deviceCredentials

    )

    But not  with  CrmServiceClient .

    I am confused .

  • Siddhesh Profile Picture
    46 on at

    Hi,

    I am facing the same issue while connecting to the Federation Online environment. Did you got any solution on this.

    Can you assist me?

    Thanks!

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