16

Hey I am having trouble connecting to an SQL Server with Java code that is running on Linux.

If I set integratedSecurity=true, then the java code fails with the following error:

WARNING: Failed to load the sqljdbc_auth.dll cause : no sqljdbc_auth in java.library.path
com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication. ClientConnectionId:b030b480-453d-4007-8151-a552150f74cd

which makes sense as there will be no sqljdbc.dll file on Linux.

But if I set integratedSecurity=false, then I get the following error:

 com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'IT_DEV_USER'.

So does anyone know how I can connect to SQL Server with integratedSecurity set to false? (Note that I cant even connect when the Java code is running on Windows when integratedSecurity is set to false.)

If not, is there any way I can get integratedSecurity working on Linux?

4 Answers 4

8

If you want to use integrated security and using JDBC Driver 4.0 or greater then you add the following in your jdbc connection string.

integratedSecurity=true;authenticationScheme=JavaKerberos

More information: http://blogs.msdn.com/b/psssql/archive/2015/01/09/jdbc-this-driver-is-not-configured-for-integrated-authentication.aspx

4
  • 2
    Have you successfully done this? I am getting a Unable to obtain Principal Name for authentication error...
    – fulhamHead
    Commented Jun 18, 2015 at 12:52
  • Try to specify the instance name, it should fix it. msdn.microsoft.com/en-us/library/ms378428.aspx
    – hamnix
    Commented Jun 18, 2015 at 13:00
  • 1
    As far as I know, just adding that kerberos needs to be used is not sufficient: you need to have kerberos configured correctly, and you need to have a kerberos ticket from the AD. Commented Jun 18, 2015 at 13:25
  • Yes, the configuration for kerberos if required is to be done. Please check the link in the answer.
    – hamnix
    Commented Jun 19, 2015 at 10:22
-1

Adding authenticationScheme=JavaKerberos works for me in Linux, but make sure to remove integratedSecurity=true since you are not using Windows.

1
  • 1
    I believe this is incorrect. From learn.microsoft.com/en-us/sql/connect/jdbc/…: "If you specify authenticationScheme=JavaKerberos but do not also specify integratedSecurity=true, the driver will ignore the authenticationScheme connection property and it will expect to find user name and password credentials in the connection string."
    – splashout
    Commented Sep 17, 2020 at 1:11
-3

You can't use integratedSecurity feature from Linux system, as it tied to windows system and uses your windows authentication. However, if you enable both SQL Server and Windows Authentication mode on your SQL Server, then you can create a login, map to corresponding database and use it in java from Linux.

To enable SQL Server authentication:

  1. Right click on your server in management studio
  2. Properties
  3. Security
  4. Server authentication -> SQL Server and Windows Authentication mode
2
  • Hey, I tried this and it still does not work. Any ideas?
    – fulhamHead
    Commented Jun 18, 2015 at 12:23
  • 1
    You should be able to use the kerberos authentication built in to the SQL Server JDBC driver. Commented Jun 18, 2015 at 13:24
-3

If you dont want Integrated Security connection, then set that parameter to false and instead provide user and password in the connURL as below:

String connectionUrl = "jdbc:sqlserver://localhost:port;databaseName=DB_NAME;integratedSecurity=false;user=login_user;password=login_pwd;";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.