尝试修改远程机器上可用的现有文件,用户凭据和路径都是正确的,并且可以访问,因为可以通过其他技术访问。现在我正在尝试从Java并获得拒绝访问。我使用了jcifs-ng-2.0.5.jar,bcprov-jdk15on-1.54.jar,slf4j-api-1.7.24.jar 请帮助我,以下是我的代码
String fileUrl = "smb://IPAddress/C$/Users/Public/TDM%20-%20Input.xlsx";
Properties cifsProps = new Properties();
cifsProps.setProperty("jcifs.smb.client.domain", "domainName");
cifsProps.setProperty("jcifs.smb.client.username", "userId");
cifsProps.setProperty("jcifs.smb.client.password", "password");
Configuration config = new PropertyConfiguration(cifsProps);
BaseContext context = new BaseContext(config);
SmbResource resource = context.get(fileUrl);
if (!(resource instanceof SmbFile)) {
throw new CIFSException("File URL does not point to a file on a network share");
}
try {
InputStream in = ((SmbFile) resource).getInputStream();
} finally {
context.close();
}