java - 无法使用 jcifs 连接到 unc 位置
问题描述
我有一些属于同一域的远程位置。当我从 Windows 访问远程位置时,它会在不要求凭据的情况下打开。但是如果我使用 java 代码(jcifs)访问该位置,那么它会给我这个异常
jcifs.smb.SmbAuthException:登录失败:未知用户名或密码错误
Java 代码是
String path=convertToSmb(loc);
NtlmPasswordAuthentication auth=new NtlmPasswordAuthentication(path, userName, passwd);
SmbFile sFile=null;
try {
sFile=new SmbFile(path,auth);
sFile.connect();
boolean sFileExists = sFile.exists();
logger.info("checkUNCLocation [END] with :: sfileExists :: "+sFileExists);
return sFileExists;
} catch (MalformedURLException e) {
logger.error(e.getMessage(), e);
return Boolean.FALSE;
} catch (IOException e) {
logger.error(e.getMessage(), e);
return UNCNetworkConnectionWrapper.connectUNCNetwork(loc, userName, passwd);
}finally{
sFile=null;
//jcifs.Config.setProperty("jcifs.smb.client.disablePlainTextPasswords", Boolean.TRUE.toString());
}
我尝试使用 net use delete 删除所有连接,但 Windows 仍然没有要求提供凭据
日志记录还显示正确的凭据。请指导应该是什么原因。
解决方案
您是否尝试过设置userName
和password
?
Windows 如何通过尝试使用当前凭据连接服务器来做到这一点,如果您与您的用户连接并且您尝试连接到同一域中的其他计算机,则连接将成功,因为您的凭据在此域中有效.
尝试使用您自己的凭据连接到“此”服务器。
推荐阅读
- javascript - HTML 仅在 Internet Explorer 中使用脚本
- algorithm - 我该如何解决这个算法问题。最佳时间和空间复杂度是多少?
- python - 在python3中编辑多个列表中的多个变量
- c# - 如何在聚合之前将值转换为 long?
- php - php laravel mailchimp curl请求不起作用
- spring - Neo4j 索引产生错误:运行查询时参考值未在偏移量 0 处初始化
- c# - 如何读取套接字流直到换行?
- javascript - 获取多个输入文件的图像预览
- ember.js - 在 javascript 文件中的 ember.js 中编辑数组
- embedded - Embedded Tcl:如何检测表达式的评估?