Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server 2008 - Login failed. The login is from an untrusted domain and cannot be used with Windows authentication

I've just installed SQL Server 2008 Developer edition and I'm trying to connect using SQLCMD.exe, but I get the following error:

H:\>sqlcmd.exe -S ".\SQL2008"

Msg 18452, Level 14, State 1, Server DEVBOX\SQL2008, Line 1

Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.

The SQL Server instance is configured to use SQL Server and Windows Authentication mode. If I specify -U sa then I can log in successfully, but I'd like to use windows authentication. Connecting using SSMS with windows authentication seems to work fine.

like image 903
Tom Hunter Avatar asked May 13 '09 15:05

Tom Hunter


People also ask

Can not connect to SQL Server Login failed for user?

The generic message “Login Failed for User (Microsoft SQL Server, Error: 18456)” means you entered invalid credentials when logging into SQL Server.

How do I enable integrated security in SQL Server?

To implement SQL Server integrated security, perform the following steps: From SQL Enterprise Manager, right-click the SQL Server name that appears in the Server Manager window and click Configure on the shortcut menu. Click Security Options. Select Windows NT Integrated as the Login Security Mode, and then click OK.


3 Answers

I had this issue and it was because the machine running the application isnt trusted for delegation on the domain by active directory. If it is a .net app running under an application pool identity DOMAIN_application.environment for example.. the identity can't make calls out to SQL unless the machine is trusted.

like image 144
Steve Avatar answered Oct 16 '22 16:10

Steve


You're not passing any credentials to sqlcmd.exe

So it's trying to authenticate you using the Windows Login credentials, but you mustn't have your SQL Server setup to accept those credentials...

When you were installing it, you would have had to supply a Server Admin password (for the sa account)

Try...

sqlcmd.exe -U sa -P YOUR_PASSWORD -S ".\SQL2008"

for reference, theres more details here...

like image 5
Eoin Campbell Avatar answered Oct 16 '22 16:10

Eoin Campbell


In my case, this error was caused by renaming my client machine. I used a new name longer than 13 characters (despite the warning), which resulted in the NETBIOS name being truncated and being different from the full machine name. Once I re-renamed the client to a shorter name, the error went away.

like image 3
cdonner Avatar answered Oct 16 '22 14:10

cdonner