5

I'm trying connect remotely to windows machine and fetch files from this machine. this is my code,

 path = path.replace(":","");
        path = path.replace("\\","/");
        String smbpath="smb://"+host+":445/"+path; //c/alon2.txt";

        NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(user+":"+password);
        SmbFile smbFile = new SmbFile(smbpath,auth);

        SmbFileInputStream input = new SmbFileInputStream(smbFile);
        Files.copy(input, destPath.toPath());
        System.out.println("completed fetching file");
        return destPath;

and I got this exception, "Plain text passwords are disabled", i tried to put jcifs.Config.setProperty("jcifs.smb.client.disablePlainTextPasswords","true"); and it doesnt work, and i dont want to disable the smb 3rd party in the server. Any idea?

java.lang.RuntimeException: Plain text passwords are disabled at jcifs.smb.SmbComTreeConnectAndX.writeParameterWordsWireFormat(SmbComTreeConnectAndX.java:129) at jcifs.smb.AndXServerMessageBlock.writeAndXWireFormat(AndXServerMessageBlock.java:94) at jcifs.smb.AndXServerMessageBlock.writeAndXWireFormat(AndXServerMessageBlock.java:166) at jcifs.smb.AndXServerMessageBlock.encode(AndXServerMessageBlock.java:65) at jcifs.smb.SmbTransport.doSend(SmbTransport.java:439) at jcifs.util.transport.Transport.sendrecv(Transport.java:67) at jcifs.smb.SmbTransport.send(SmbTransport.java:655) at jcifs.smb.SmbSession.sessionSetup(SmbSession.java:316) at jcifs.smb.SmbSession.send(SmbSession.java:218) at jcifs.smb.SmbTree.treeConnect(SmbTree.java:176) at jcifs.smb.SmbSession.logon(SmbSession.java:147) at jcifs.smb.SmbSession.logon(SmbSession.java:140) at com.hp.autopass.usagehub.service.util.osutils.NetBiosConnection.authenticate(NetBiosConnection.java:47) at com.hp.autopass.usagehub.service.NetBiosConnectionTest.authenticateTest(NetBiosConnectionTest.java:34) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)

user2303962
  • 85
  • 1
  • 2
  • 9

1 Answers1

5

You should use jcifs.Config.setProperty("jcifs.smb.client.disablePlainTextPasswords","false"); to enable plain text passwords. In your code you set this flag as true.

Nirmal Raghavan
  • 531
  • 5
  • 19
  • I have a same problem and when I tried to add specified configuration it throws another exception Exception in thread "main" jcifs. Sm. SmbException: 0xC000009A at jcifs.smb.SmbTransport.checkStatus(SmbTransport.java:563) at jcifs.smb.SmbTransport.send(SmbTransport.java:663) at jcifs.smb.SmbSession.sessionSetup(SmbSession.java:316) at jcifs.smb.SmbSession.send(SmbSession.java:218) at jcifs.smb.SmbTree.treeConnect(SmbTree.java:176) at jcifs.smb.SmbFile.doConnect(SmbFile.java:911) at jcifs.smb.SmbFile.connect(SmbFile.java:957) at jcifs.smb.SmbFile.connect0(SmbFile.java:880) – Lusi Nov 16 '16 at 08:48
  • On to the next step then ;) http://stackoverflow.com/questions/9317300/jcifs-smbexception – Edd Feb 01 '17 at 17:52