Skip to main content

Notifications

Announcements

No record found.

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

  • Suggested answer
    mppowe1 Profile Picture
    mppowe1 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
    Tiklu Ganguly 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
    AndrewCampey 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
    Nithya Gopinath 17,076 on at
    RE: Create CrmServiceClient for ADFS

    Hi Andrew,

    Please refer the link below.

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

  • David Jennaway Profile Picture
    David Jennaway 14,063 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
    ScottDurow 19 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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 231,493 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans