How to connect to Database with Active Directory Authentication Type

Hello,

I am unable to connect to the Database using my Active Directory credentials. The database I am trying to connect to does not have any direct SQL logins and we can only access it using Active Directory.

Every time I try to connect, it says “Cannot open server requested by logon”.

Please help.

image

I have downloaded and added the “sqljdbc_auth.dll” file into the Katalon_Studio_Windows_64-5.6.0\jre\bin folder. Tried the 32 bit and 64 bit file.

I have tried adding “Authentication=ActiveDirectoryIntegrated;integratedSecurity=True” to the connection string.

I am getting the error “Connection Failed! This driver is not configured for integrated authentication”

Not sure if I should be entering a User and Password.

I am using the connection URL “jdbc:sqlserver://fake-01.database.windows.net;databaseName=RA34363T;IntegratedSecurity=True;”

Can someone please help? I have attached pictures of the error I am getting in Katalon and how I connect in SSMS successfully.

Shout out: @ThanhTo @duyluong

lets summon my grandson
@Mihai_Augustin_Sarat nepoate, do you still have the script we used ?

@anpatel
I don’t have access anymore to the exact code, but the script was somewhat like this.
In cmd you type:

runas /netonly /user:domain\username “C:\path_to\ssms.exe”

And in Katalon we had a custom keyword that would handle the connection and the queries. We did not use the Katalon’s test data feature.
This example is for MySQL and not T-SQL. Please update the required fields to form a T-SQL connection.
https://docs.katalon.com/katalon-studio/docs/connect_db_gui_testing.html

1 Like

thanks grandson. i think starting from this we can extrapolate a working solution by using various tweaks (execute powershell or dig into powershell objects)

I was hoping there would be a more simple way of connecting. I would like to use Katalon’s test data feature and was hoping to get some guidance on what is wrong with the Connection URL and if I should or should not be checking the “Secure user and password” checkbox.

Hey,
So I investigated this further and if you do not have a Integrated Security=true or Trusted_Connection=true it will not work.
If you do not have the above mentioned, the only thing is using a dedicated sql user. Just ask your dba team and why you need it (you can even go to managers to escalate this and make sure you get a result). They will gladly help you. I just did sth similar in my current project. It involved some discussions but eventually the dba team gave up (they were blocking the progress of the entire automation project), bended some rules and I walked with the needed user.
@Ibus what we did on the previous project is a little different. We already had the user.

1 Like

@Mihai_Augustin_Sarat that’s why i summoned you on this matter, you are younger and more patient than I :slight_smile:
i am getting older and starting to mix memories …

public class dbtesting {
private static Connection connection = null;

def connection(String server, String port, String dbname, String username, String password) {
	String url = "jdbc:sqlserver://" + server + ":" + port + ";databaseName=" + dbname + ";user=" + username + ";password=" + password + ";IntegratedSecurity=true"

	
	connection = DriverManager.getConnection(url)
}

}

This is custom keyword which I am using to connect to sqlserver but its getting failed.
at TempTestCase1580391392461.run(TempTestCase1580391392461.groovy:23)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException:
This driver is not configured for integrated authentication. ClientConnectionId:00fe6130-0b9a-4c90-8dc3-a8833cfbdc17
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1745)
at com.microsoft.sqlserver.jdbc.AuthenticationJNI.(AuthenticationJNI.java:58)

What am i missing ? thanks for any help

hi,

check this page

and here how to use it
public static void main(String[] args) {
ActiveDirectoryAuthentication authentication = new ActiveDirectoryAuthentication(“YOUR.DOMAIN.COM”);
try {
boolean authResult = authentication.authenticate(“Username”, “password”);
System.out.print("Auth: "; + authResult);
} catch (LoginException e) {
e.printStackTrace();
}
}

Hi,

I getting error in “package org.webmoli.ad.auth”; that unexpected token .
How to resolve this issue??

Thanks.

hi,

remove this “package org.webmoli.ad.auth;” cause it’s example project package

After removing that package I am getting other five error message.

hi,

and the errors are?
show your script here

SQL Server Db connection for window authentication is working for me with below code

def connection(String server, String port, String username, String Password, String dbname) {
	String url = "jdbc:sqlserver://" + server + ":" + port + ";databaseName=" + dbname  + ";IntegratedSecurity=true"

	connection = DriverManager.getConnection(url)

When we connect through window authentication no need to pass username and password.