gpt4 book ai didi

java - 使用 JDBC(Java) 的 Active Directory 密码连接

转载 作者:行者123 更新时间:2023-12-02 03:10:03 24 4
gpt4 key购买 nike

我正在尝试使用 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 检查它并已连接。请帮忙。我正陷入困境。任何帮助将不胜感激。

最佳答案

根据评论,错误已自行解决:

这是一些 JAR 问题。现在它使用 JDBC 连接到 Azure 目录密码身份验证模式。

我将此作为答案发布,这可能对其他社区成员有益。

关于java - 使用 JDBC(Java) 的 Active Directory 密码连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57000974/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com