Getting The login is from an untrusted domain and cannot be used with Integrated authentication

3.9k Views Asked by At

I have a windows authentication user created on SQL server. I am trying to connect SQL server using that user, but I am getting java.sql.SQLException: The login is from an untrusted domain and cannot be used with Integrated authentication. error.

I am using jtds-1.3.jar. My connection url is jdbc:jtds:sqlserver://xyz.net:1433;instance=dev;databaseName=XYZ;integratedSecurity=true;useNTLMv2=true;domain=XYZ.net

I have checked the connection and traffic is allowed between my client machine and server. I tried setting intgratedSecurity= false as suggested in other answers but that did not work.

What properties of user should I check to know that user is correctly configured on SQL sever for JDBC connectivity?

2

There are 2 best solutions below

1
Nikhil Padole On BEST ANSWER

Finally, got this connection working. It turns out the best way to connect to SQL server using jTDS driver is to create SQL server user avoid creating windows user. And stick to SQL server based user.

0
rpet On

The message The login is from an untrusted domain and cannot be used with Integrated authentication can be misleading. For example you can get it by entering the right username with the wrong password.

Without knowing the exact configuration of your SQL server is difficult to say but I would try with a simpler connection string:

jdbc:jtds:sqlserver://xyz.net:1433;databaseName=XYZ

I don't use jTDS directly but the version embedded inside Aqua Data Studio and we don't use named instances but, anyway, I provide the configuration I use with freeTDS in a Linux box as an example of a simple configuration that works perfectly against an cluster instance of SQL Server 2014.

In /etc/freetds/freetds.conf:

[conn1]
    host = host.dom.ain
    port = 1433
    tds version = 7.4

Query from the command line using tsql:

/usr/bin/tsql -S conn1 -U DOMAIN\\USER << SQL_DATA
SELECT getdate();
GO
QUIT
SQL_DATA

Password: 
locale is "es_ES.utf8"
locale charset is "UTF-8"
using default charset "UTF-8"
1> 2> 
11-11-2022 01:26
(1 row affected)