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?

migrated from stackoverflow.com Aug 22 '12 at 12:18

This question came from our site for professional and enthusiast programmers.

  • It worked after I used same account as on the mssql server. – user30638 Nov 18 '13 at 11:14

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.

  • Yes the authentication needs mirrored!. My application which is a service was running under different windows account(x) than the SQL Server Management Studio. This windows account (x) is also present in the other system, but both had different passwords!!!!!!! I made the password same in both the systems and it worked. Thanks many!! – jebina Aug 21 '12 at 13:44

If you are using Windows 7, you might have to "run as administrator". This will allow the app to reuse your windows credentials and pass them to the SQL Server. Otherwise, you will pass guest credentials to the SQL Server.

  • 3
    Unlikely. UAC only influences local interactions. It does not affect authentication with a remote host. – Remus Rusanu Aug 21 '12 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy