Overview
When there are multiple Active Directories’ Farms in a domain sharing the same AD Instance with Federation as the Authentication Type, then there would be one Primary / Default Active Directory and the other as Secondary Active Directories.
If the CRM is installed on the Secondary Active Directory, there might be issues with connectivity through Organization Service.
What is Home Realm Discovery?
Home Realm Discovery (HRD) is an AD FS feature where the end user gets to choose which Authentication Provider they want to authenticate against from the available Claims Provider Trusts.
This is what it looks like out of the box. This shows 1 additional Claims Provider.
Here, we will show you how to connect to Organization Service using Home Realm address.
First, we need to get Home Realm Address from the Network Administrator
In the second step, add home Realm URI in your web.config file by using following method
[code language="csharp"]
[/code]
Then in C# code, add the following:
[code language="csharp"]
//Cridentials
var credentials = new ClientCredentials();
credentials.UserName.UserName = "UserName";
credentials.UserName.Password = "Password";
//Organization Service URL
var OrgUrl = new Uri("YourOrganizationURl");
//Home Realm URL
string homeRealmUri = System.Configuration.ConfigurationManager.AppSettings.Get("homeRealmUri");
//Organization Service Proxy
if (string.IsNullOrEmpty(homeRealmUri))
{
service = new OrganizationServiceProxy(_organizationUri, new Uri(homeRealmUri), userCredentials, null);
}
else
{
service = new OrganizationServiceProxy(_organizationUri, null, userCredentials, null);
}
service.EnableProxyTypes();
IOrganizationService svc = (IOrganizationService)service;
[/code]
Once the above code is added, IOrganizationService would be created and you can use it to make CRM transactions.
I look forward to seeing what you’ll do with Organization Service and Home Realm in Microsoft Dynamics 365.
If you have any question or queries, do not hesitate to reach out to us!