DEV Community

The Juanito Learns Show
The Juanito Learns Show

Posted on • Originally published at jptarqu.blogspot.com on

Can use Integrated Security via .net but not via JDBC

I encountered an obscure issue when trying to connect to a SQL Server database using Windows Integrated Authentication from Java. My JDBC URL was correct but I kept getting the following error:

com.microsoft.sqlserver.jdbc.SQLServerException: Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.

And the SQL logs in the SQL server were showing the following:

SSPI handshake failed with error code 0x80090346, state 46 while establishing a connection with integrated security; the connection has been closed. Reason: The Channel Bindings from this client are missing or do not match the established Transport Layer Security (TLS) Channel. The service might be under attack, or the data provider or client operating system might need to be upgraded to support Extended Protection.

The puzzling thing was that I was able to connect fine suing the system.data.sqlclient from .net and from SQL Server Management Studio from the same machine and domain account that was getting the JDBC error. In addition, Integrated Authentication was working fine when connecting to other SQL servers. So, it had to do something with that particular server. After searching in the internet, I found that the issue is due to the JDBC not implementing the Channel Binding feature needed to connect to SQL servers whose Extended Protection is turned on. The native SQL Client does implement that feature and because the system.data.sqlclient from .net and SSMS use the native SQL Client under the covers, the connection for those succeeds. The following link takes you to the issue in GitHub for this scenario: https://github.com/microsoft/mssql-jdbc/issues/963

Top comments (0)