How to formate JNDI to authenticate with a domain user instead of SQL user

302 views Asked by At

I have a working JNDI with SQL server username and password in my Java application. It throws NameNotFoundException when I try to change the user to my domain user instead of SQL user.

Here it is mentioned I only have to provide integratedSecurity as true. Have I missed anything in my JNDI?

JNDI with SQL Server User:

<Resource
name="jdbc/MyJNDI"
auth="Container"
type="javax.sql.DataSource"
maxTotal="100"
maxIdle="30"
maxWaitMillis="1000"
validationQuery="select 1"
testOnBorrow="true"
testOnConnect="true"
testOnReturn="true"
testWhileIdle="true"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://localhost:1433;database=survey;user=myuser;password=mypassword;"
/>

My JNDI with domain user:

<Resource
name="jdbc/MyJNDI"
auth="Container"
type="javax.sql.DataSource"
maxTotal="100"
maxIdle="30"
maxWaitMillis="1000"
validationQuery="select 1"
testOnBorrow="true"
testOnConnect="true"
testOnReturn="true"
testWhileIdle="true"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://localhost:1433;database=survey;integratedSecurity=true;"
/>
1

There are 1 answers

1
vadzim dvorak On

Another driver is necessary. See this source http://www.bigdata-unleashed.com/20150930/database-ntlm-authentifizierung

<Resource
name="jdbc/MyJNDI"
auth="Container"
type="javax.sql.DataSource"
maxTotal="100"
maxIdle="30"
maxWaitMillis="1000"
integratedSecurity="true"
validationQuery="select 1"
testOnBorrow="true"
testOnConnect="true"
testOnReturn="true"
testWhileIdle="true"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
driverClassName="net.sourceforge.jtds.jdbc.Driver"
url="jdbc:jtds:sqlserver://localhost:1433;database=survey;"
/>

Database driver is available at http://sourceforge.net/projects/jtds/files/jtds/