Login Failed: The Account Is Disabled (Error 18470)

🚨Part of the SQL Server Errors series, the exact messages and what actually causes them.Related pillar: Security

Msg 18470  ·  Level 14  ·  State 1
Login failed for user 'ErrDemoDisabled'. Reason: The account is disabled.
⚡Enable is one line; the real question is why it was off. sys.server_principals modify_date tells you when it changed, and the default trace names whatever is still knocking.

The login exists, and SQL Server refuses it because the account is disabled. Unlike a wrong password, where the client gets a deliberately vague message and the real reason hides in the server error log, a disabled account says so. On a current driver the client sees the reason directly:

sqlcmd -S localhost -U ErrDemoDisabled -P "<password>" -C -Q "SELECT 1"
sqlcmd in PowerShell: Login failed for user ErrDemoDisabled. Reason: The account is disabled, from ODBC Driver 18

A wrong password on the same driver comes back as just Login failed for user, with no reason. The server error log has the same attempt, with the client address:

EXEC sys.xp_readerrorlog 0, 1, N'ErrDemoDisabled';
SSMS: xp_readerrorlog filtered on the login, four Logon rows reading Reason: The account is disabled with the CLIENT address

If the word disabled appears anywhere in the message, skip the password reset. The password may even be right, and none of that matters until the login is switched back on.


Why This Happens

Logins do not disable themselves. Someone or something did it:

  • A leaver or security process. Disabling instead of dropping is the correct practice for accounts that might own objects or might need to come back, so tidy environments produce this error by design.
  • The sa lockdown. Disabling sa is standard hardening, and anything still configured to connect as sa starts failing with exactly this the moment it happens.
  • Policy lockout confusion. An account locked out by Windows password policy reports a different reason, but the two get mixed up in tickets constantly. The message text settles it: disabled means disabled.
  • A restore or migration. Logins scripted from another server with Generate-LoginScript style tooling carry their disabled state with them, which is correct behaviour that surprises people.

Confirm the Login Is Disabled

SELECT name,
       is_disabled,
       type_desc,
       modify_date
FROM sys.server_principals
WHERE name = N'ErrDemoDisabled';
SSMS: sys.server_principals showing ErrDemoDisabled with is_disabled 1, SQL_LOGIN and its modify_date

is_disabled = 1 is the whole diagnosis, and modify_date tells you when it changed. Who changed it is a separate question, covered below.


The Fix

ALTER LOGIN [ErrDemoDisabled] ENABLE;

That is genuinely all, but before running it, ask the question the error is really raising: was this account disabled on purpose? If it belonged to a leaver, the fix is not enabling it, the fix is finding out what is still trying to use it, which the next section does.

Per Microsoft’s ALTER LOGIN reference, disabling does not end sessions that are already connected, and on the lab one kept running queries after the DISABLE. To stop a leaver now, find their session in sys.dm_exec_sessions and KILL it.


What Is Still Trying to Use It

The default trace records every failed login, and it names more than the error log does: the host, the application and its process ID. That is usually enough to find the job, service or connection string still using the account.

-- Failed logins for the account, from the default trace
DECLARE @path nvarchar(260) = (SELECT path FROM sys.traces WHERE is_default = 1);

SELECT t.StartTime,
       t.LoginName,
       t.HostName,
       t.ApplicationName,
       t.ClientProcessID
FROM sys.fn_trace_gettable(@path, DEFAULT) AS t
WHERE t.EventClass = 20   -- Audit Login Failed
  AND t.LoginName = N'ErrDemoDisabled'
ORDER BY t.StartTime DESC;
SSMS: default trace Audit Login Failed rows for the login with host HPAI01, application SQLCMD and each client process ID

The default trace rolls over, so on a busy server it may only reach back hours. Run it while the failures are still happening.


Who Disabled It

Not the default trace. On SQL Server 2025 it recorded the login being created and every failed attempt, but nothing for ALTER LOGIN ... DISABLE. A server audit with SERVER_PRINCIPAL_CHANGE_GROUP does record it, as action LGDA, with the login that ran it, but only if the audit was running before it happened:

-- Read an existing server audit for changes to the login
SELECT event_time,
       action_id,                  -- LGDA = disabled, LGEA = enabled
       server_principal_name AS changed_by,
       statement
FROM sys.fn_get_audit_file(N'D:\Audit\*.sqlaudit', DEFAULT, DEFAULT)   -- your audit's file path
WHERE statement LIKE N'%ErrDemoDisabled%'
ORDER BY event_time DESC;
SSMS: server audit file showing LGDA for ALTER LOGIN DISABLE and LGEA for ENABLE, both run by HPAI01\Peter

With no audit, modify_date gives you the time, and the change record has to give you the rest.


When It Is Not This

If the message says nothing about the account being disabled you are in ordinary 18456 territory, where the client is told State 1 and the truth lives server-side. And if logins fail in a burst across many accounts, look at the domain and the server rather than any single login.


Frequently Asked Questions

Why does the client see the reason when a wrong password stays vague?
A wrong password is deliberately vague so the message cannot be used to probe accounts. A disabled account is treated as safe to announce on current drivers, which makes this the one login failure you can diagnose from the client message alone.
Should I enable it or recreate it?
Enable it. Dropping and recreating a login generates a new SID for SQL logins, which orphans every database user mapped to it. Enabling changes nothing but the flag.
How do I find out who disabled it?
modify_date in sys.server_principals gives you when. The default trace does not record the DISABLE; a server audit with SERVER_PRINCIPAL_CHANGE_GROUP does, if it was already running.
Does disabling the login disconnect it?
No. Per Microsoft’s ALTER LOGIN reference, disabling does not affect connections that already exist; it stops the next login. The account also keeps its permissions and can still be impersonated with EXECUTE AS. If the point is to stop someone now, find their sessions in sys.dm_exec_sessions and KILL them after the DISABLE.

Where To Go Next

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *