Sql-server – SQL Server 2008: The login is from an untrusted domain and cannot be used with Windows authentication

sql serversql-server-2008

The question here is different from 1 & 2

When trying to connect to a SQL Server database that is on another system in the network both are in workgroup, when attempting to connect to a SQL Server 2008 instance using SQL Server Management Studio with Windows authentication, I get connected.

But when trying to connect from my application, I get the following error

(Login failed. The login is from an untrusted domain and cannot be
used with Windows authentication.) Native=18452).

If SQL Server Management Studio can connect, what would be required for my application to get connected?

Best Answer

Since you are running in a workgroup the only possible authentication is one using 'mirrored NT accounts', which means that the process trying to authenticate must be running under an identity that is 'mirrored' on the host that is authenticating the process. 'Mirrored' accounts are distinct local accounts with identical name and password on both hosts doing the authentication.

So it must follow that you're running SSMS from an account that it is mirrored on the SQL Server host (eg. <computername>\Administrator, which is mirrored by the <sqlhost>\Administrator and has the same password). Note that UAC has nothing to do here (ie running as administrator will not help).

Your application is probably running under a different local account (default IIS appool perhaps?) and the account under which the application runs is not mirrored on the SQL Server host.

Your best solution is to ditch the makeshift network and deploy a proper AD (domain). As an interim, make sure you run your application under an account that is mirrored on thew SQL Server host machine.