Close this search box.

ADFS Domain auto completion

When your domain is federated with Office 365, during your authentication session you are redirected to your ADFS servers to authenticate. You must then enter your Active Directory email address and password to access Office 365. If your company domain is long, such as, I suggest you provide your users with auto-completion of your domain name. In order to do this, you need to modify your local ADFS Template.

Script source:

For more information on how to customize your ADFS infrastructure, click on the link below:

1. First, create a new Template, by copying the default one. You will then make your modifications on this one, to avoid modifying the default Template of ADFS.

PS C:\Users\John> New-AdfsWebTheme -Name Fabrikam -SourceName default

2. Then, export the Template to your location.

PS C:\Users\John> Export-AdfsWebTheme -Name Fabrikam -DirectoryPath c:\theme

3. Look for the file onload.js in the folder C:\theme\script\ and add the following lines to the end of the document:

//remove domain name requirement
function runScript(e) {
if (e.keyCode == 13) {
return Login.submitLoginRequest();

var AppendUPN = function () {
var userName = document.getElementById(Login.userNameInput);
var lowerUserName = userName.value.toLowerCase();

//Check to see if they already included the UPN
var li = lowerUserName.lastIndexOf(’ );
if (li ==-1)
userName.value = userName.value + ;

return true;

document.getElementById(‘submitButton’).onclick = new Function(‘AppendUPN();return Login.submitLoginRequest();’);
document.getElementById(‘passwordInput’).onkeypress = runScript;

4. To replace the file we just modified in our custom theme, using Power Shell, run the command below:

PS C:\Users\John> Set-AdfsWebTheme -TargetName Fabrikam -AdditionalFileResource @{Uri=’ /adfs/portal/script/onload.js’;path=”C:\Temp\script/onload.js”}

5. Finally, to activate your new theme :

PS C:\Users\John> Set-AdfsWebConfig -ActiveThemeName Fabrikam

Want to migrate or connect your phone system to Teams?

Write to me and let's keep in touch!


Formulaire de contact

Discutons ensemble de vos projets


Contact form

Let's discuss your projects together