1

I want to connect to my local PostgreSQL using SSPI. I have changed the pg_hba.conf file to look like for both IPv4 and IPv6 :

host    all             userName        127.0.0.1/32            sspi
host    all             all             127.0.0.1/32            md5

When I'm trying to connect to the database using PgAdmin, I don't need to specify password for the userName, whereas I need for user postgres. From this I can understand that SSPI is working.

Now, when I'm trying to validate the connection using jdbc e.g.

String url = "jdbc:postgresql://127.0.0.1:5432/dbName";
Connection conn = DriverManager.getConnection(url);
System.out.println(conn.isValid(10));

I'm getting the error:

java.lang.RuntimeException: NTDSAPI DsMakeSpn call failed with 87

Notes:

I have tried:

String url = "jdbc:postgresql://127.0.0.1:5432/dbName?gsslib=sspi"

and

Connection conn = DriverManager.getConnection(url, props) //where props have only username.

and I also have tried this

Connection conn = DriverManager.getConnection(url, "userName", ""); //empty password.

Nothing seems to work.

1ac0
  • 2,875
  • 3
  • 33
  • 47
naoumm
  • 69
  • 1
  • 1
  • 5

0 Answers0