Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

[Help] Creating Connection String

Posted on by Microsoft Employee

For the past week I've been following every video, and tutorial on the web and have not been able to create a successful connection string.

My company has a server established remotely and when i try to connect to our test environment it will not successfully authenticate the string.

Here is the setup:

  • The address for the computer itself is set up as: "Test.company.com"  <-----*This just points to the server as shown below.*

IIS

  • The address used to log into the CRM installed in that machine is: "CRMTest.company.com"
  • The CRM server is using AD authentication so we type our usernames like so: ad\username

7411.q.PNG

  • Once logged in CRM shows in the "About" section: "This program is liscenced to organization: CRMTest"

With all this information I should be able to create the string no problem, but

Whenever I try to make the connection string it won't log on, it'll find the server, but refuses to authenticate any help would be appreciated.

*This post is locked for comments

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: [Help] Creating Connection String

    When you say, you are trying to create a connection string, this is in order to develop a custom solution using the SDK?

    Since you are using ADFS, you are set to https and IFD (based on the url above):

    You connection string should be as follows (inside you app.config):

     <connectionStrings>

       <add name="Server=company.com, organization=crmtest, user=admin@company.local"

            connectionString="Url=server.company.gov/.../Organization.svc; Username=ad\admin; Password=CRM_PASSWORD; authtype=IFD"/>

     </connectionStrings>

     <appSettings>

       <add key="UserName" value="ad\admin"/>

       <add key="EncryptedPassword" value="SADWTZWDpPusc4rFx0DT8g==" />

       <add key="InternalUrl" value="server.company.com"/>

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

     </appSettings>

    Your application settings above are options since there are multiple ways to connect to environment:

    Make sure to add reference to Microsoft.Xrm.Tooling.Connector (in using section)

    Connect using Connection String:

    connectionString = connectionString.Replace("CRM_PASSWORD", CRM_PASSWORD);

    CrmServiceClient conn = new CrmServiceClient(connectionString);

    Connect using Application Settings:

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

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

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

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

    AuthenticationType authType = AuthenticationType.IFD;

    CrmServiceClient conn = new CrmServiceClient(creds, authType, internalUrl, "443", orgName, true, true, null);

    After the CrmServiceClient has been established, set the Organization Service:

    _orgService = (IOrganizationService)conn.OrganizationWebProxyClient != null ? (IOrganizationService)conn.OrganizationWebProxyClient : (IOrganizationService)conn.OrganizationServiceProxy;

    Hope this helps.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans