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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Create CrmServiceClient for ADFS

(0) ShareShare
ReportReport
Posted on by

I've been reading the information I can find about Dynamics 365 and most of the examples show connections using a connection string.

Anyone know why this is?

Before I change to using Connection Strings has anyone connected to ADFS using CrmServiceClient and populating the variables? Something like the following

CrmServiceClient dynamicsService = new CrmServiceClient(new System.Net.NetworkCredential(Username, Password), AuthenticationType.IFD, Url, Port, Organisation, false, true, OrganizationDetail);

Fails for me every time.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    mppowe1 Profile Picture
    5 on at
    RE: Create CrmServiceClient for ADFS

    Andrew, not sure if you're still dealing with this since it's years later.  But I had this issue stump me for the longest time, where I was using a connectionString in a config file with on-prem IFD using HomeRealmUri, and it wouldn't work.  I eventually dug into Microsoft's Xrm.Tooling.Connector and found that if you set the AuthType to IFD, it IGNORES the HomeRealmUri parameter in your connection string.  So HomeRealmUri only works if you manually specify it in the code in the CrmServiceClient constructor (though then the AuthType says it's "Claims"... but still seems to work).

    Just thought I'd pass this along since I lost sooo much time to this issue

  • Tiklu Ganguly Profile Picture
    302 on at
    RE: Create CrmServiceClient for ADFS

    Hi Scott,

              What would be the connection string where the Azure AD is getting connected via ADFS and we are using Online d365?

    Thanks

    Tiklu

  • AndrewCampey Profile Picture
    on at
    RE: Create CrmServiceClient for ADFS

    Sorry for the delay!  The following works but I can't get this to work using variables

    string connect = @"AuthType = IFD; Url = <<URL>/<<OrgName>; HomeRealmUri=https://<<HomeRealm>/adfs/services/trust/mex/;Domain=<<Domain>; Username=<<User>@<<domain>; Password=<<Password>";

    EDIT:- So the issue is the above allows me to include the home realm and set the Auth Type as IFD and it connects.

    I can't seem to find somewhere to set HomeRealmUri and still use IFD. Am I missing something?

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at
    RE: Create CrmServiceClient for ADFS

    Hi Andrew,

    Please refer the link below.

    See: msdn.microsoft.com/.../dn688177.aspx

  • David Jennaway Profile Picture
    14,065 on at
    RE: Create CrmServiceClient for ADFS

    What error do you get, and can you connect using other classes (e.g. OrganizationServiceProxy) ? If you can't, then the issue is likely to be with the ADFS configuration - there are scenarios where ADFS is incorrectly setup in a way that the UI client works, but programmatic access fails

  • ScottDurow Profile Picture
    21 on at
    RE: Create CrmServiceClient for ADFS

    Hi Andrew,

    I've done this lots of time yes! Have you tried adding the domain?

    CrmServiceClient crmSvc = new CrmServiceClient(new System.Net.NetworkCredential("<UserName>", "<Password>", “<Domain>”), AuthenticationType.IFD, "<Server>", "<Port>", "<OrgName>", useUniqueInstance:false, useSsl:false, <orgDetail>);
    

    From: https://msdn.microsoft.com/en-gb/library/dn688177.aspx#IFD 

    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

Responsible AI policies

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

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
Christoph Pock Profile Picture

Christoph Pock 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans