Connect to SQL server using jdbc with AD username and password

Schuetze, Peter 1 Reputation point
2020-08-27T19:10:08.373+00:00

We want to In order to avoid SQL server accounts we want to use Active directory accounts in out java programs to connect to SQL server. We are not always able to use integrated security (e.g. different applications running on the same Wildfly instance should use different AD accounts). Is it possible to supply AD user name and password for the connection and what connection properties need to be set?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,052 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Erland Sommarskog 103.2K Reputation points MVP
    2020-08-27T21:25:44.597+00:00

    No, that is not possible. Integrated security assumes that you have already been authenticated by Windows. To login with username + pass, SQL authentication is the way to go.

    1 person found this answer helpful.
    0 comments No comments

  2. m 4,271 Reputation points
    2020-08-28T03:09:11.917+00:00

    Hi @Schuetze, Peter ,

    Is it possible to supply AD user name and password for the connection and what connection properties need to be set?

    No, it isn’t. As ErlandSommarskog’s reply, with configuring “integratedSecurity=true;” in connection string, JDBC will use the current Windows account on which the Java application runs to log in SQL Server. With the “user=MyUserName;password=*****;” in connection string, the "user" here is a valid SQL Server login rather than a Windows account. Please reference: http://technet.microsoft.com/en-us/library/ms378428.aspx

    More information: Connecting a Java Program to SQL Server , Java connect MS SQL Server using windows authentication

    BR,
    Mia
    If the reply is helped, please do “Accept Answer”.--Mia

    0 comments No comments