Search code examples
javagrailsjcifs

JCIFS Access is denied


I'm using JCIFS to write to a windows share. This has been working fine. All of a sudden it stopped working and I'm now getting a jcifs.smb.SmbAuthException: Access is denied. exception. I know that my credentials are good as I can connect using smb manually and write to the folder, so that's not the problem. The code I'm using is:

NtlmPasswordAuthentication ntlm = new NtlmPasswordAuthentication(domain, userName, smbPassword);
SmbFile file = new SmbFile(smbPath, ntlm);

SmbFileOutputStream outputStream = new SmbFileOutputStream(file)

outputStream.write(fileContents)
outputStream.close()

It blows up on the "SmbFileOutputStream outputStream = new SmbFileOutputStream(file)" line. None of this has changed for months and has been working fine, so I'm not sure why it would stop working. Does anyone have any ideas? I'm at a complete loss here since I know my credentials are good and that I do have write access


Solution

  • As indicated by the error message and what you are describing it is a file permission issue on the target server.

    Updated Confirmed (via comments) that it was a permissions issue when attempting to replace an existing file.