Sql-server – execute as login for nonexistent login successful

sql serversql-server-2008sql-server-2008-r2sql-server-2012

On Sharepoint database server, we found 18456 state 11: infrastructure error for account Domain\machineA$ every 10 minutes and nt authority\anonymous every hour.

I checked syslogins but didn't find login and xp_logininfo didn't return results.

I Ran "Execute as login=domain\machineA$" and it was successful…. That is strange

I executed sys.logins_tokens and it returned 10 groups(like 'Public', \Everyone, S-1-19-1012-33).but no one was there as login in sql server.

Please here help me in finding –> How Was i able to Ran "execute as login=domain\machineA$" successfully while login doesn't exist.

Best Answer

As Erland marked in https://social.msdn.microsoft.com/Forums/sqlserver/en-US/ad6a80b1-717c-4d08-ae51-2eb029e59738/execute-as-login-for-nonexistent-login-successful?forum=sqldatabaseengine#ad6a80b1-717c-4d08-ae51-2eb029e59738

Yes, you can do EXEUTE AS LOGIN on a Windows login which exists in the AD, even if that login does not have permission to log into SQL Server.

The topic for EXECUTE AS in Books Online, includes this caution box: The EXECUTE AS statement can succeed as long as the Database Engine can resolve the name. If a domain user exists, Windows might be able to resolve the user for the Database Engine, even though the Windows user does not have access to SQL Server. This can lead to a condition where a login with no access to SQL Server appears to be logged in, though the impersonated login would only have the permissions granted to public or guest.