您好,这是我要测试DFS配置的代码
SmbConfig config = SmbConfig.builder()
.withMultiProtocolNegotiate(true)
.withSigningRequired(true)
.withDfsEnabled(true)
.build();
this.client = new SMBClient(config);
this.connection = client.connect(serverName);
this.ac = new AuthenticationContext(username, password.toCharArray(), domain);
this.session = connection.authenticate(ac);
this.share = (DiskShare) session.connectShare(sharename);
for( FileIdBothDirectoryInformation item : this.share.list("myprojectname\\testfoldername") ){
System.out.println(item.getFileName()+" ");
}
File f = this.share.openFile("myprojectname\\testfoldername\\try-a-new-file.txt",
new HashSet<>(Arrays.asList(AccessMask.FILE_ADD_FILE)),
new HashSet<>(Arrays.asList(FileAttributes.FILE_ATTRIBUTE_NORMAL)),
SMB2ShareAccess.ALL,
SMB2CreateDisposition.FILE_OPEN_IF,
new HashSet<>(Arrays.asList(SMB2CreateOptions.FILE_DIRECTORY_FILE))
);
我在share.openFile
行看到错误
com.hierynomus.mssmb2.SMBApiException:STATUS_ACCESS_DENIED (0xc0000022):无法创建.....
为什么会发生这种情况,在那创建文件是否锁定权限?有趣的是,我可以通过Mac的Finder连接到同一共享,并可以在其中创建文件,也可以使用jcifs进行尝试,并且可以正常工作。