Skip to content

Added check for MSAL library when attempting ActiveDirectoryServicePrincipal authentication#1759

Merged
lilgreenbird merged 1 commit intomicrosoft:mainfrom
caseyhall:main
Mar 3, 2022
Merged

Added check for MSAL library when attempting ActiveDirectoryServicePrincipal authentication#1759
lilgreenbird merged 1 commit intomicrosoft:mainfrom
caseyhall:main

Conversation

@caseyhall
Copy link
Copy Markdown
Contributor

Minor change. This check exists for other AD auth cases, but will just throw java.lang.ClassNotFoundException if ActiveDirectoryServicePrincipal is used and MSAL libraries are not in the classpath. In another project, I had spent some time trying to determine the issue, only to notice this missing check would have been helpful.

This just adds the check used in other AD auth cases to the ActiveDirectoryServicePrincipal case.

Caused by: java.lang.NoClassDefFoundError: com/microsoft/aad/msal4j/IClientCredential
at com.microsoft.sqlserver.jdbc.SQLServerConnection.getFedAuthToken(SQLServerConnection.java:5341)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.onFedAuthInfo(SQLServerConnection.java:5293)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.processFedAuthInfo(SQLServerConnection.java:5180)
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onFedAuthInfo(tdsparser.java:305)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:128)

now returns:

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Failed to load MSAL4J Java library for performing ActiveDirectoryServicePrincipal authentication.
at com.microsoft.sqlserver.jdbc.SQLServerConnection.getFedAuthToken(SQLServerConnection.java:5333)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.onFedAuthInfo(SQLServerConnection.java:5290)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.processFedAuthInfo(SQLServerConnection.java:5177)
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onFedAuthInfo(tdsparser.java:305)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:128)

Thanks

@Jeffery-Wasty
Copy link
Copy Markdown
Contributor

Thank you for the contribution @caseyhall. We'll take a look and get back to you.

@lilgreenbird lilgreenbird added this to the 10.3.0 milestone Mar 3, 2022
@lilgreenbird lilgreenbird merged commit 8806c17 into microsoft:main Mar 3, 2022
@lilgreenbird lilgreenbird changed the title Add check for MSAL library when attempting ActiveDirectoryServicePrincipal authentication Added check for MSAL library when attempting ActiveDirectoryServicePrincipal authentication Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants