Connecting to MS SQL Server with NTLM on Linux
A MS SQL Server instance can be configured to use NTLM authentication for connections so that it goes against Active Directory for authentication and authorization. There is a “Type 4” (pure Java) JDBC driver provided by Microsoft. When the server is configured for NTLM, however, there is a DLL that needs to be in the classpath (e.g. \windows\system32, which paradoxically holds 64-bit DLLs), sqljdbc_auth.dll
.
Including a DLL is problematic when running Java on a non-Windows host. There is an open source library that can access MS SQL Server, http://jtds.sourceforge.net/. Getting the URL correct is tricky because of the parameters that need to be supplied. The URL I found that works is:
jdbc:jtds:sqlserver://<serverhost>;useNTLMv2=true;user=<userid>;databaseName=<definedDbName>;domain=<NTLM Domain>;instance=<"Other" database name>