smbj - STATUS_ACCESS_DENIED for DFS

0

Hi here is my code that I am trying to test a DFS configuration

     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))
    );

I get the error at on the share.openFile line as

com.hierynomus.mssmb2.SMBApiException: STATUS_ACCESS_DENIED (0xc0000022): Create failed for .....

Why can this be happening, is it lock of permissions to create a file there? The interesting thing is I can connect to the same share via my Mac's Finder and can create files there, also tried with jcifs and it worked.

java
smb
dfs
smbj
asked on Stack Overflow Aug 29, 2018 by mcvkr • edited Apr 5, 2019 by mcvkr

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0