hierynomus / smbj

Server Message Block (SMB2, SMB3) implementation in Java
Other
713 stars 180 forks source link

Authentication error : STATUS_ACCESS_DENIED (0xc0000022): Create failed #706

Open kumarav12 opened 2 years ago

kumarav12 commented 2 years ago

hi Team,

i am migrating my application to use SMB2 protocol using smbj package. i am getting STATUS_ACCESS_DENIED (0xc0000022): Create failed. Below is the code which i have used to make the connection. i checked my credentials and access as well , i am using the same for SMB1 connection. Please guide me what i am doing wrong.

SMBClient client = new SMBClient(); try (Connection connection = client.connect(serverName)) { AuthenticationContext ac = new AuthenticationContext(userName, password.toCharArray(), domain); Session session = connection.authenticate(ac);

        // Connect to Share
        try (DiskShare share = (DiskShare) session.connectShare(shareName)) {
            Directory remoteSmbjDirectory = (Directory) share.open(folderName, EnumSet.of(AccessMask.MAXIMUM_ALLOWED), null, 
                    SMB2ShareAccess.ALL, SMB2CreateDisposition.FILE_OPEN, null);
            System.out.println("Access Flag: " + remoteSmbjDirectory.getFileInformation().getAccessInformation().getAccessFlags());

        }
    }