So, I'm trying to write a file from an Android device to a Windows shared folder. I am using the latest version of JCIFS and the code that shows the available network resources works fine. Therefore, I assume that everything is fine with JCIFS and my local network, WiFi, etc. Here is the code to download the file (in fact, I just want to write the Sring text to the file):
public boolean save2Samba(String text, String fileName) { try {
Since the URL is registered, I am sure that it is correct (also I checked the URL using the code mentioned above and it looks through the folder).
But the problem is that I always get the same:
W/System.err(3214): jcifs.smb.SmbAuthException: Access is denied.
The shares are not password protected, so I do not need any username and password for access. I could read / write / delete files from another WinPC, and authorization is not required. I also tried to create a password for the user on WinPC with shares, but the result was the same. So I tried several versions of NtlmPasswordAuthentication with no luck:
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(""); NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(":"); NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("Administrator:"); //actual username on WinPC with shares NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("Administrator"); NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null,"Administrator",""); NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null,"","");
So, what am I doing wrong and how to achieve my goal, when there is no authorization, do I need to access the shared folder?
BTW my Samsung TV, based on Linux and using the samba client, has access to the same shared folder without problems and play MP3s there (well, yes, this is just a read). Since my AOS device has access to my local network via WiFi (instead of a TV connected via Ethernet), I also checked access to the shared folder using a laptop + WiFi and did not find any problems.
Added:
I am trying to execute the following lines:
file = new SmbFile(url, auth); android.util.Log.i("save2Samba", "file.exists(): " + file.exists());
and getting the same access is prohibited. I am not even trying to write a file ...