In the previous blog (Implementing Active Directory Federation Services step-by-Step) I have showed you how to install and configure Active Directory Federation Services (ADFS) in your internal network and DMZ, capable of handling Office 365 authentication request. In this blog I’ll show you how to configure Office 365 and how to test it.
In a typical managed domain, the user accounts and password hashes are synchronized to Azure Active Directory. Office 365 uses Domain Controllers in Azure AD to authenticate the users and grant them access to the resources in the cloud.
In a federated domain, the user accesses the Office 365, but access is denied, and the request is redirected to Azure Active Directory. There, the home realm (the user’s domain) is discovered and the request is redirected to the ADFS server based on the home realm. If my user account is email@example.com, my home realm is exchangelabs.nl and the request is redirected to the federation server that was created earlier, and that was used to configure the domain in Azure Active Directory.
I did a session on this at IT Dev Connections in 2017 (in San Francisco), the following is one animated slide that can be downloaded which shows the flow between a client, Office 365, Azure AD and the on-premises ADFS and Domain Controller:
To get this working, the domain in Azure Active Directory needs to be converted to a federated domain so that Azure AD knows any authentication request needs to be redirected to the on-premises ADFS environment.
When adding a domain to Azure Active Directory it is automatically created as a managed domain. As said before, authentication takes places against Domain Controllers in Azure AD. You can check a domain using the Get-MsolDomain -DomainName exchangelabs.nl PowerShell command as shown in the following screenshot:
To convert this to a federated domain, start a PowerShell command (with elevated privileges) and enter the following commands:
[PS] C:\> Connect-MsolService
[PS] C:\> Set-MsolADFSContext -Computer ams-adfs01.labs.local
[PS] C:\> Convert-MsolDomainToFederated -DomainName Exchangelabs.nl
Note. Use the FQDN of the local first ADFS server with the Set-MsolADFSContext command, not the federation URL
This will connect the existing on-premises infrastructure to Azure AD, and convert the domain to a federated domain. Now, when checking the domain in Azure AD using the same command as before you’ll see it now is a federated domain:
In in the ADFS Management Console you’ll a new Relying Party Trust (RPT) for use with Office 365:
To get more into detail in Azure AD about the federation settings, you can use the Get-MsolDomainFederationSettings command which shows more information:
Clearly visible are the Logon, Issuer and LogOffUri, which point to our on-premises ADFS implementation. Even more information can be retrieved using the Get-MsolFederationProperty command as shown in the following screenshot:
To test the new configuration, navigate to the Microsoft Online Portal and login using an account with the domain we just configured, i.e. firstname.lastname@example.org:
When selecting this account, Azure AD determines the home realm (exchangelabs.nl) and redirect to the on-premises URL as found in the federation settings in Azure AD. You’ll see this happen on the fly in your browser:
And a few seconds later we are redirected to our on-premises ADFS environment:
Clearly visible is the Federation Service display Name which was configured with the first ADFS server in the previous blogpost.
Enter your password, and how wonder, MFA is still working as well (which was a pleasant surprise for me 😊):
Another interesting test is using the Remote Connectivity Analzyer ( (https://aka.ms/exrca) which has a Single Sign-On test. Navigate to the Remote Connectivity Analyzer, click the Office 365 tab and select the Office 365 Single Sign-On test radio button.
Enter username and password, do the verification code test and await the results. You’ll see something similar as the following screenshot:
The logon attempt was successful, but more interesting is that you can expand all test steps to see what’s going on under the hood and try to understand how ADFS works.
In the previous two blogposts I demonstrated how to install and configure ADFS in your on-premises infrastructure. I installed only one ADFS server and one WAP proxy, which is far from a high available environment. Why high available? Without the ADFS server it is no longer possible to logon to any Office 365 service, so a high available infrastructure is a requirement for any ADFS implementation.
But customers are moving to the cloud to decommission their on-premises solutions, and with ADFS we’re building an on-premises solution for authenticating cloud solutions. But for compliancy reasons it might be needed to authenticate against local domain controllers (no passwords in the cloud for example). On the other hand, you can use Pass Through Authentication (PTA, see my blogpost Azure AD Connect Pass-through authentication) for this as well. PTA doesn’t offer as much possibilities as ADFS yet, but it is improving.
Is ADFS future proof? Some people say it isn’t, but as long as I find articles like What’s new in Active Directory Federation Services for Windows Server 2019 on the Microsoft website I don’t see too many issues with that.
- ADFS Content Map (Wiki) – https://social.technet.microsoft.com/wiki/contents/articles/2735.ad-fs-content-map.aspx#Office_365
- Implementing Your AD FS Design Plan – https://docs.microsoft.com/en-us/windows-server/identity/ad-fs/deployment/implementing-your-ad-fs-design-plan
- AD FS 2016 Deployment Guide – https://docs.microsoft.com/en-us/windows-server/identity/ad-fs/deployment/ad-fs-deployment-guide
- Windows Server 2012 R2 AD FS Deployment Guide – https://docs.microsoft.com/en-us/windows-server/identity/ad-fs/deployment/windows-server-2012-r2-ad-fs-deployment-guide
- Securing Cloud Resources with Azure Multi-Factor Authentication and AD FS – https://docs.microsoft.com/en-us/Azure/active-directory/authentication/howto-mfa-adfs
- When to Use an Authorization Claim Rule – https://docs.microsoft.com/en-us/windows-server/identity/ad-fs/technical-reference/when-to-use-an-authorization-claim-rule
- OWA and ECP login with AD FS through the WAP – https://vandijk.cloud/owa-and-ecp-login-with-ad-fs-through-the-wap/
- AD FS user sign-in customization – https://docs.microsoft.com/nl-nl/windows-server/identity/ad-fs/operations/ad-fs-user-sign-in-customization
- Advanced Customization of ADFS for Cloud Usage (Part 2 of 4) – https://blogs.technet.microsoft.com/pauljones/2015/05/26/advanced-customization-of-adfs-for-cloud-usage-part-2-of-4/
- Advanced Customization of ADFS for Cloud Usage (Part 3 of 4) – https://blogs.technet.microsoft.com/pauljones/2015/05/26/advanced-customization-of-adfs-for-cloud-usage-part-3-of-4/
- Advanced Customization of ADFS for Cloud Usage (Part 4 of 4) – https://blogs.technet.microsoft.com/pauljones/2015/05/26/advanced-customization-of-adfs-for-cloud-usage-part-4-of-4/