Add check for MSAL library when attempting ActiveDirectoryServicePrincipal auth
@@ -5328,6 +5328,10 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
break;
} else if (authenticationString
.equalsIgnoreCase(SqlAuthentication.ActiveDirectoryServicePrincipal.toString())) {
+ if (!msalContextExists()) {
+ MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_MSALMissing"));
+ throw new SQLServerException(form.format(new Object[] {authenticationString}), null, 0, null);
+ }
// aadPrincipalID and aadPrincipalSecret is deprecated replaced by username and password
if (aadPrincipalID != null && !aadPrincipalID.isEmpty() && aadPrincipalSecret != null
