jcifs.smb.SmbAuthException: Access is denied

2019-08-26 04:43发布

问题:

Trying to modify existed file which is available in remote machine, user credentials and path all are correct and can be accessible since from other technology able to access. now i'm trying from Java and getting access denied. I used jcifs-ng-2.0.5.jar,bcprov-jdk15on-1.54.jar,slf4j-api-1.7.24.jar Please help me, Below is my code

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();
}
标签: java jcifs