Search code examples
javaubuntuspring-bootntlmsmb

jcifs.smb.SmbAuthException though user name and password are correct on Ubuntu


We are working on spring boot application. In our application we have to share folder from remote machine from any OS. We are sharing folders to get the list of objects exist in shared folder. We are using SMB and NTLMAuthentication for it.

For authentication :

  NtlmPasswordAuthentication credential = new NtlmPasswordAuthentication(
                    informationStoreDefinition.getProperties().get(DOMAIN),
                    informationStoreDefinition.getProperties().get(USER),
                    informationStoreDefinition.getProperties().get(PASSWORD)
            );

Later we are trying to get list of shared folder using the code :

 SmbFile file = ((CifsContainerObject) simpleObject).smbFile;
 SmbFile[] list = file.listFiles();

We have tried these combinations to access/share the folder :

  • Windows OS to Ubuntu - WORKING!!
  • Windows OS to Windows OS - WORKING!!
  • Ubuntu to Windows - FAILED
  • Ubuntu to Ubuntu - FAILED

We are getting this error for above two case : jcifs.smb.SmbAuthException: Logon failure: unknown user name or bad password.

Code throw error at line : SmbFile[] list = file.listFiles();. Our user name, password and domain all are correct. We have accessed folder of Linux on Windows our network, we are successfully able to access the share folder as well as we are getting response on our Windows machine for Linux shared folder. Then why this error thrown?


Solution

  • For sharing folder I am using the steps are -

    • Right click on folder which you want to share

    • Click on the properties

    • Go to Local Network Share tab

    • Check other boxes

    Then follow these link - https://askubuntu.com/questions/19361/cant-access-ubuntus-shared-folders-from-windows-7

    http://ubuntuhandbook.org/index.php/2014/05/ubuntu1404-file-sharing-samba/