1

do you know the way i have to configure my web project to be able to connect to sql server with windows authentication? what i need is to use the user credentials to access to the database, i will use

Apache tomcat 7
JSF 2.1.2

Do tou know if this is posible?

DuSant
  • 970
  • 12
  • 25
  • possible duplicate of [How can I connect to SQL Server using integrated security with the JDBC driver?](http://stackoverflow.com/questions/4629718/how-can-i-connect-to-sql-server-using-integrated-security-with-the-jdbc-driver) – Kevin Panko May 28 '14 at 20:31

1 Answers1

3

Yes, it is possible.

You will need the sqljdbc_auth.dll. There's 3 places you can place it:

  1. in your WEB-INF/lib of the application
  2. In your Tomcat's lib folder
  3. In C:\windows\system32. Possible problems. The dll is distributed with the JDBC driver of Microsoft: http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11774

In your connection string, use integratedSecurity=true; (example: jdbc:sqlserver://MyServer;databaseName=MyDatabase;integratedSecurity=true;)

Update 1: found this post on Stackoverflow for more info.

Simon Arsenault
  • 1,777
  • 17
  • 35
  • Thanks @Simon Arsenault , basically I dont need to add any user or pass right? Tomcat will take the windows credentials to access sql server instance? – DuSant May 27 '14 at 19:56
  • Is it going to be for each users? Because that is what i am looking ... the user accessing the web page to be anthenticated... is it posible? – DuSant May 27 '14 at 20:32
  • Found this that helps too [link](http://stackoverflow.com/questions/12523865/jdbc-simple-mssql-connection-example-not-working/12524566#12524566) – DuSant May 27 '14 at 23:32
  • It will use the windows credentials of the user running the tomcat process/service. – Simon Arsenault May 28 '14 at 01:38
  • Why do you want to use the credentials of the user loggued into your application? What are you trying to achieve? – Simon Arsenault May 28 '14 at 01:45
  • Use different users to connect to the database in order to have more efficiency, but i am thinking not to do that... i guess is not posible – DuSant May 28 '14 at 05:48
  • 1
    Why would it be more efficient? And yes, I would suggest that you use a connection pool with the user running Tomcat. – Simon Arsenault May 28 '14 at 12:02