我正在尝试使用 com.hierynomus.smbj v0.10.0 连接到 SMB 服务器。连接正常,但一旦我尝试进行身份验证,我就会收到此异常:
com.hierynomus.mssmb2.SMBApiException: STATUS_ACCESS_DENIED (0xc0000022): Authentication failed for 'USERNAME' using com.hierynomus.smbj.auth.NtlmAuthenticator@4152d38d
at com.hierynomus.smbj.connection.Connection.authenticate(Connection.java:194)
at MyTest.smbj(MyTest.java:...)
这是测试代码,看看我在做什么:
@Test
void smbj() throws Exception {
SMBClient client = new SMBClient();
try (Connection connection = client.connect("my-smb-server.de")) {
AuthenticationContext ac = new AuthenticationContext("USERNAME", "PASSWORD".toCharArray(), "DOMAIN");
Session session = connection.authenticate(ac);
// ... do more here ...
}
}
SMB 服务器和连接非常好,因为我可以使用多个 GUI 工具(例如 ForkLift)从运行测试的同一台机器进行连接,而无需任何自定义设置。
connection.getConnectionInfo()
在进行身份验证之前返回这个:
成功连接到:my-smb-server.de ConnectionInfo{
serverGuid=975b39d3-55c0-4490-84e7-80371b734ce7,
serverName='my-smb-server.de',
negotiatedProtocol=NegotiatedProtocol{dialect=SMB_2_1, maxTransactSize=8388608, maxReadSize =8388608, maxWriteSize=8388608},
clientGuid=85863c1f-0328-4c21-9a72-b3d907b23a1d,
clientCapabilities=[SMB2_GLOBAL_CAP_DFS],
serverCapabilities=[SMB2_GLOBAL_CAP_DFS, SMB2_GLOBAL_CAP_LEASING, SMB2_GLOBAL_CAP_LARGE_MTU], > clientSecurityMode=0,
serverSecurityMode=3,
server='null' }
非常感谢任何帮助。