Skip to main content

WinRM returns 401 for a local administrator: LocalAccountTokenFilterPolicy

· 3 min read
CertAutoPilot Team
CloudNativeWorks

You point a deployment tool at a Windows server over WinRM, use a local administrator account with NTLM, and get HTTP 401. The password is right; the account is in the local Administrators group. The reason is usually not the password at all but UAC remote restrictions.

What happens​

When UAC is on, Windows gives a local account that signs in over the network a filtered token with administrator rights stripped, unless it is the built-in Administrator account. WinRM requires administrator rights for a remote shell, so it refuses the request with 401 even though the sign-in itself succeeded. Domain accounts are not filtered this way, which is why the same setup often works with a domain account.

How to confirm it​

Look at the Security log on the target server at the time of the attempt:

  • Event 4624 (successful logon, logon type 3) followed by the 401 means the password was accepted and the refusal is about rights. This is the UAC case.
  • Event 4625 means the sign-in itself failed. The Sub Status code says why: 0xC000006A wrong password, 0xC0000064 no such user (often a domain name filled in for a local account), 0xC0000072 disabled, 0xC0000234 locked out.

Then check the setting:

Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System |
Select-Object LocalAccountTokenFilterPolicy, EnableLUA

EnableLUA = 1 means UAC is on. If LocalAccountTokenFilterPolicy is missing or 0, local administrators are filtered on remote sign-in.

The fix​

New-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System `
-Name LocalAccountTokenFilterPolicy -Value 1 -PropertyType DWord -Force

No restart is needed. Two notes before you apply it everywhere:

  • It applies to every local administrator account on the server, not only the one your tool uses. Where you can, prefer a domain account (and Kerberos), which needs no such exception.
  • Set it through Group Policy or your server image rather than by hand, so it survives a rebuild.

Other 401 causes worth ruling out​

We reproduced the common ones on a lab server; the authentication schemes the server offers in its 401 response narrow it down:

SymptomCause
401, server offers Negotiate only, on port 5985Unencrypted HTTP is not allowed (AllowUnencrypted=false); use HTTPS on 5986, or allow it
401, server offers Basic onlyNegotiate (NTLM) authentication is turned off on the WinRM service
401 with event 4624 and no 4625Authenticated but not authorized: not an administrator, or the UAC filtering above
HTTP 500 "Access is denied"The account is only in Remote Management Users; a remote shell needs Administrators

CertAutoPilot's IIS, Windows (WinRM) and Exchange targets report which of these it saw in the error message itself. The full catalogue is in the WinRM troubleshooting guide.