我正在尝试使用Active Directory密码身份验证模式连接到SQL Server。但是在执行代码时,出现以下错误:
[pool-2-thread-1] INFO com.microsoft.aad.adal4j.AuthenticationAuthority
- [Correlation ID: 2febb587-963f-462a-9937-98b05d3a3fc8] Instance
discovery was successful
[pool-2-thread-1] ERROR com.microsoft.aad.adal4j.AuthenticationContext -
[Correlation ID: 2febb587-963f-462a-9937-98b05d3a3fc8] Execution of
class com.microsoft.aad.adal4j.AcquireTokenCallable failed.
java.lang.ClassCastException: java.util.Collections$SingletonList cannot
be cast to java.lang.String
at com.nimbusds.oauth2.sdk.util.URLUtils.serializeParameters(URLUtils.java:88)
at com.microsoft.aad.adal4j.AdalTokenRequest.toOAuthRequest(AdalTokenRequest.java:160)
at com.microsoft.aad.adal4j.AdalTokenRequest.executeOAuthRequestAndProcessResponse(AdalTokenRequest.java:86)
at com.microsoft.aad.adal4j.AuthenticationContext.acquireTokenCommon(AuthenticationContext.java:930)
at com.microsoft.aad.adal4j.AcquireTokenCallable.execute(AcquireTokenCallable.java:70)
at com.microsoft.aad.adal4j.AcquireTokenCallable.execute(AcquireTokenCallable.java:38)
at com.microsoft.aad.adal4j.AdalCallable.call(AdalCallable.java:47)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: Failed to authenticate the user e9002802@ltfinc.net in Active Directory (Authentication=ActiveDirectoryPassword).
at com.microsoft.sqlserver.jdbc.SQLServerADAL4JUtils.getSqlFedAuthToken(SQLServerADAL4JUtils.java:57)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.getFedAuthToken(SQLServerConnection.java:3853)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.onFedAuthInfo(SQLServerConnection.java:3829)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.processFedAuthInfo(SQLServerConnection.java:3797)
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onFedAuthInfo(tdsparser.java:261)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:103)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:4545)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3406)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$100(SQLServerConnection.java:85)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:3370)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7347)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2713)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2261)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1921)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1762)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1077)
at com.microsoft.sqlserver.jdbc.SQLServerDataSource.getConnectionInternal(SQLServerDataSource.java:1025)
at com.microsoft.sqlserver.jdbc.SQLServerDataSource.getConnection(SQLServerDataSource.java:69)
at main.AADUserPassword.main(AADUserPassword.java:22)
Caused by: java.util.concurrent.ExecutionException:
com.microsoft.aad.adal4j.AuthenticationException:
java.util.Collections$SingletonList cannot be cast to java.lang.String
at com.microsoft.sqlserver.jdbc.SQLServerADAL4JUtils.getSqlFedAuthToken(SQLServerADAL4JUtils.java:55)
... 18 more Caused by: com.microsoft.aad.adal4j.AuthenticationException: java.util.Collections$SingletonList cannot be cast to java.lang.String
at com.microsoft.sqlserver.jdbc.SQLServerADAL4JUtils.getSqlFedAuthToken(SQLServerADAL4JUtils.java:50)
... 18 more
我不知道那个异常(不能转换为java.lang.string)到底是什么意思;我也给了正确的用户名和密码。我使用sql server management studio检查了它,并建立了连接。 请帮忙。我已经解决了。任何帮助将不胜感激。
答案 0 :(得分:0)
根据评论,错误由他自己解决:
这是一些JAR问题。现在,它使用JDBC连接到Azure目录密码身份验证模式。
我将其发布为答案,这可能对其他社区成员有益。