---
title: 'ADFS 2019: Allow logon with sAMAccountName'
url: 'https://patrik.kernstock.net/blog/adfs-2019-allow-logon-with-samaccountname'
markdown: 'https://patrik.kernstock.net/blog/adfs-2019-allow-logon-with-samaccountname.md'
date: '2021-06-09'
description: 'Active Directory Federation Services (ADFS) allows plenty of customizations when it comes to the website theme. One specific customization allows the logon using just the sAMAccountName (e.g. awesome-admin) instead of the UPN (User Principal Name) (e.g. awesome-admin@example.com), by modifying the …'
taxonomy:
  category:
    - Microsoft
  tag:
    - ADFS
    - QuickTip
    - Windows
    - 'Windows Server'
---

# [ADFS 2019: Allow logon with sAMAccountName](https://patrik.kernstock.net/blog/adfs-2019-allow-logon-with-samaccountname)

   June 9, 2021  (updated July 24, 2022)   1 min 

   [Microsoft](https://patrik.kernstock.net/category:Microsoft)    [ADFS](https://patrik.kernstock.net/tag:ADFS) [QuickTip](https://patrik.kernstock.net/tag:QuickTip) [Windows](https://patrik.kernstock.net/tag:Windows) [Windows Server](https://patrik.kernstock.net/tag:Windows%20Server)  

 Note

This article is more than 5 year(s) old – information may be outdated.

 ![ADFS 2019: Allow logon with sAMAccountName](https://patrik.kernstock.net/images/2/0/2/1/-/2021-06-0617-54-17-pjgjjv6c-fa682981.jpg?g-b3a1b014 "ADFS 2019: Allow logon with sAMAccountName") 

Active Directory Federation Services (ADFS) allows [plenty of customizations](https://docs.microsoft.com/en-us/windows-server/identity/ad-fs/operations/ad-fs-user-sign-in-customization) when it comes to the website theme.

One [specific customization allows the logon using just the sAMAccountName](https://docs.microsoft.com/en-us/windows-server/identity/ad-fs/operations/advanced-customization-of-ad-fs-sign-in-pages#example-2-accept-sam-account-name-as-a-login-format-on-an-ad-fs-form-based-sign-in-page) (e.g. `awesome-admin`) instead of the UPN (User Principal Name) (e.g. `awesome-admin@example.com`), by modifying the behavior via a few lines of JavaScript code. However this implementation does not work with ADFS 2019 anymore, as this release ships with a completely new default theme.

I’ve modified the code to work for the latest ADFS2019 theme.
Follow following steps to implement this:

1. Clone the default template: (only needed to be done once)

    ```powershell
    New-AdfsWebTheme –Name custom –SourceName DefaultAdfs2019
    ```
2. Export the new custom theme:

    ```powershell
    Export-AdfsWebTheme –Name custom –DirectoryPath c:\theme
    ```
3. Open `onload.js` in any editor of your choice (notepad does the job as well)
4. **APPEND** the content from `onload.add.js` from below GitHub repository to `onload.js` **AT THE END**:
    <https://github.com/patschi/adfs-themes/tree/master/remember-user-and-auto-domain>
5. Save the modified `onload.js` command:

    ```powershell
    Set-AdfsWebTheme -TargetName custom -OnLoadScriptPath "c:\theme\script\onload.js"
    ```
6. Change the current default template: (only needed to be done once)

    ```powershell
    Set-AdfsWebConfig -ActiveThemeName custom
    ```

Hope this helps someone!

### Changelog

- 2022-07-24: Based on Martins feedback from the comments I have added support for "Update Password" page. Also the entire code base was reworked and code moved to GitHub.

##     Comments    

 Sort by: 

Loading comments...

---

## Navigation

- Parent: [Blog](https://patrik.kernstock.net/index.md)
- Previous: ["Downscaling" SupervisorControlPlaneVM's from three to two nodes](https://patrik.kernstock.net/blog/downscaling-supervisorcontrolplanevms-from-three-to-two-nodes.md)
- Next: [Avi/NSX ALB: Deleting httppolicyset via CLI](https://patrik.kernstock.net/blog/nsx-alb-avi-deleting-httppolicyset-via-cli.md)
