smbj
smbj copied to clipboard
STATUS_ACCESS_DENIED (0xc0000022): Authentication failed when accessing Windows Secure share with SMB_3_1_1
We are trying to access a Windows Secure share. For testing purposes we forced to use the dialect SMB_3_1_1. With it and other SMB dialects we get the rror message
STATUS_ACCESS_DENIED (0xc0000022): Authentication failed for [username]
We are unable to determine any issue with the configuration of the user or the share. The share however enforces the usage of SMB3 with SMB encryption. Our share support believes that this is caused by the library not having implemented SMB encryption.
Does the library support SMB encryption? Is there any other reason this issue could pop up?
Okay, apparently it was required to explicitly use .withEncryptData(true)
I am now trying to write a file, but run into an error com.hierynomus.mssmb2.SMBApiException: STATUS_ACCESS_DENIED (0xc0000022): Create failed for [URL]
My current code is as follows:
Set<FileAttributes> fileAttributes = new HashSet<>();
fileAttributes.add(FileAttributes.FILE_ATTRIBUTE_ENCRYPTED);
Set<SMB2CreateOptions> createOptions = new HashSet<>();
createOptions.add(SMB2CreateOptions.FILE_RANDOM_ACCESS);
String dateString = new SimpleDateFormat("yyyy-MM-dd_HH-mm").format(new Date()).toString();
File f = share.openFile(
workbookfolder+"\\"+"testfile_" + dateString + ".txt",
new HashSet(Arrays.asList(new AccessMask[]{AccessMask.GENERIC_ALL})),
fileAttributes,
SMB2ShareAccess.ALL,
SMB2CreateDisposition.FILE_OVERWRITE_IF,
createOptions);
OutputStream oStream = f.getOutputStream();
oStream.write(fileContents.getBytes());
oStream.flush();
oStream.close();
I also had FILE_ATTRIBUTE_NORMAL though this resulted in the same problem.
I presume there is some sort of attribute issue but I am not sure which this could be. I have another share that allows SMB1 and doesn't have any security/encryption enabled, where writing files works perfectly fine.
How do I find what settings I need to make here?
HI chaosof99, are u able to resolve this issue?
You should try with EnumSet.of(AccessMask.FILE_WRITE_DATA). Typically SMB_3_1_1 does not permit use of very wide access masks.