SQL Server Express Windows Authentication error

Published by marco on

Since the beginning of the year, I’ve been plagued by an intermittent error while connecting to SQL Server Express with default Windows authentication:

“Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. (Microsoft SQL Server, Error: 18452)”

The first time I encountered it, I was only able to fix it by logging out of Windows and logging back on. The second time, it went away the next morning after I’d logged back in after hibernation. I recently ran into the problem again and wanted to get to the bottom of it. Restarting SQL Server Express had no effect.

After some dead-end search results, I found an answer at the following page: SQL Server 2008 Windows Auth Login Error: The login is from an untrusted domain (StackOverflow):

“Make sure you aren’t connected to a VPN on another domain\user”

That was the answer for me: I was indeed connected to a customer VPN using SonicWall. Instead of just authenticating to the database with the user that I’d used to log in to Windows (my primary login), Windows was using the login that I’d used to connect to the VPN. It’s unfortunate that Windows cannot do the right thing in this case, but the solution is to log out of the VPN, after which SQL Server Express once again works as expected with Windows authentication.