Based on feedback in the comments on this answer, the situation is this:
There is an explicitly-created BUILTIN\Administrators
group login in SQL Server that has been denied CONNECT
to the database engine.
There is no other sysadmin
-level login available, including the NT AUTHORITY\SYSTEM
login that gets created by default.
SQL Server does not allow a user to disable the BUILTIN\Administrators
login, but it can still be denied CONNECT
. I consider this a bug, as it's obvious that the inability to disable the login outright was hard-coded into the engine to avoid scenarios like this.
I'm unable to get in after applying that permission.
You will have to either find a way to edit the contents of the master
database to get rid of the DENY
permission (totally unsupported, and at your own peril), reinstall the database engine from the installation media, or I suppose you could attempt to brute-force the sa
password.
I don't believe you can simply rebuild master
as that requires connecting and authenticating against the database engine, which isn't available here.
sys.server_principals
joined withsys.server_role_members
I realized that there are 2 moresysadmin
s in my server: the accounts used by the servicesMSSQLSERVER
andSQLSERVERAGENT
. You can useservices.msc
or the configuration manager to find what user name your services are using, and then find a way to impersonate them.