Active Directory authentication using managed identity is not working
ashranjol opened this issue · 4 comments
Driver version
Provide the JDBC driver version (e.g. 10.2.0).
12.4.2.jre8
also the dependency azure-identity 1.9.0
SQL Server version
Provide the output of executing SELECT @@VERSION
on your target SQL Server.
Microsoft SQL Azure (RTM) - 12.0.2000.8
Client Operating System
Provide the Operating System the client application is running on.
linux
JAVA/JVM version
Provide the JAVA/JVM version (e.g. java version "1.8.0").
1.8.0
Table schema
Provide the table schema to repro the issue.
out of scope
Problem description
We are using mssql-jdbc to connect to one of our azure sql server using managed identity and when I set Authentication type as ActiveDirectoryMSI
or ActiveDirectoryManagedIdentity
I get the error stating that it's not supported.
The documentation https://learn.microsoft.com/en-us/sql/connect/jdbc/connecting-using-azure-active-directory-authentication?view=sql-server-ver16#connect-using-activedirectorymanagedidentity-authentication-mode states that version 12.2 or 12.4 should support these two types of authentication.
Expected behavior
A connection to database
Actual behavior
Getting error
Error message/stack trace
Complete error message and stack trace.
Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: The authentication value "ActiveDirectoryManagedIdentity" is not valid.
at com.microsoft.sqlserver.jdbc.SqlAuthentication.valueOfString(SQLServerDriver.java:92)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1236)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:866) at com.microsoft.sqlserver.jdbc.SQLServerDataSource.getConnectionInternal(SQLServerDataSource.java:968) at com.microsoft.sqlserver.jdbc.SQLServerDataSource.getConnection(SQLServerDataSource.java:69)
at com.relativity.c4.executionmanager.dao.DbInstance.<init>(DbInstance.scala:38) at com.relativity.c4.executionmanager.util.ComponentRegistry.dbInstance$lzycompute(ComponentRegistry.scala:44) at com.relativity.c4.executionmanager.util.ComponentRegistry.dbInstance(ComponentRegistry.scala:43) at com.relativity.c4.executionmanager.util.ComponentRegistry$MyDbComponent.$init$(ComponentRegistry.scala:47) at com.relativity.c4.executionmanager.util.ComponentRegistry$$anon$4.<init>(ComponentRegistry.scala:92) at com.relativity.c4.executionmanager.util.ComponentRegistry.jobDao$lzycompute(ComponentRegistry.scala:92) at com.relativity.c4.executionmanager.util.ComponentRegistry.jobDao(ComponentRegistry.scala:92) at com.relativity.c4.executionmanager.util.ComponentRegistry.jobService$lzycompute(ComponentRegistry.scala:162) at com.relativity.c4.executionmanager.util.ComponentRegistry.jobService(ComponentRegistry.scala:160) at com.relativity.c4.executionmanager.util.ComponentRegistry.<init>(ComponentRegistry.scala:272) at com.relativity.c4.executionmanager.ExecutionManagerApp$.main(ExecutionManagerApp.scala:51) at com.relativity.c4.executionmanager.ExecutionManagerApp.main(ExecutionManagerApp.scala)
Any other details that can be helpful
Add any other context about the problem here.
JDBC trace logs
Provide the JDBC driver trace logs. Instructions can be found here: https://docs.microsoft.com/sql/connect/jdbc/tracing-driver-operation
Hi @ashranjol,
I'm not sure you are using the correct version of the driver, as the line numbers from the error don't match up with what is expected in versions 12.2 - 12.4. Can you please re-download 12.4.2 (or better yet, the latest stable version 12.6.0) and let us know if this fixes the issue. You can get the driver from either Maven, here on GitHub, or from our Microsoft documentation releases page here.
Also, make sure your application is picking up the jar file from the location you think it's picking it up from. Based on the line numbers, you are probably loading a 6.x version from somewhere else. Search your system for mssql-jdbc*.jar.
Hi @ashranjol,
Is further assistance needed? Without further communication, we'll assume the issue is resolved, and close the issue.
Hi @Jeffery-Wasty
I was able to test with the correct driver and we are able to connect. It was indeed a driver version issue. Thank you for the help :)