Skip to content Skip to sidebar Skip to footer

Write/upload A File Using Samba/jcifs Issue (smbauthexception: Access Is Denied)

So I'm trying to write a file from android device to windows shared folder. I'm using latest version of JCIFS and code which displays available network shares works fine. So I assu

Solution 1:

OMG!!! Solution was so simple!!! To access network which is not login/password protected and thus doesn't need any authorization is not NtlmPasswordAuthentication.ANONYMOUS BUT it is:

NtlmPasswordAuthenticationauth=newNtlmPasswordAuthentication(null, null, null);

damn it wasn't that obvious!

Solution 2:

try with this code

 NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("",
                            username, password);
    sharepath = "smb://" + pathtosharefolder + test.txt;  


 sFile = new SmbFile(sharepath, auth);
    SmbFileOutputStream out = new SmbFileOutputStream(file, true);
    out.write(text.getBytes());

Also check you have share the folder path that you are accessing. Also check it has given write permission to the folder

Post a Comment for "Write/upload A File Using Samba/jcifs Issue (smbauthexception: Access Is Denied)"