AgNO3 / jcifs-ng

A cleaned-up and improved version of the jCIFS library
GNU Lesser General Public License v2.1
313 stars 104 forks source link

Breaking on error command=SMB2_SESSION_SETUP,status=More data is available.,flags=0x0001,mid=1,wordCount=0,byteCount=0 #229

Open FerPalos opened 4 years ago

FerPalos commented 4 years ago

I am getting this error while trying to connect to a remote server. I quite new in all about the conection, negotiaton, and so on... my config is:

jcifsProperties.setProperty("jcifs.smb.client.enableSMB2", "true"); jcifsProperties.setProperty("jcifs.smb.client.disableSMB1", "true"); jcifsProperties.setProperty("jcifs.traceResources", "true"); jcifsProperties.setProperty("jcifs.resolveOrder", "BCAST,LMHOSTS,DNS"); jcifsProperties.setProperty("jcifs.smb.client.ipcSigningEnforced", "false"); jcifsProperties.setProperty("jcifs.smb.client.disablePlainTextPasswords", "false"); jcifsProperties.setProperty("jcifs.smb.client.dfs.disabled", "true"); jcifsProperties.setProperty("jcifs.smb.client.useSMB2Negotiation", "true"); jcifsProperties.setProperty("jcifs.smb.client.requireSecureNegotiate","false"); jcifsProperties.setProperty("jcifs.smb.client.minVersion", "SMB202"); jcifsProperties.setProperty("jcifs.smb.client.maxVersion", "SMB210"); jcifsProperties.setProperty("jcifs.smb.useRawNTLM", "false"); jcifsProperties.setProperty("jcifs.smb.client.disableSpnegoIntegrity", "true");

And my logs are:

05-28 16:35:00.742 16913-16984/smt4v.paquete.samba D/jcifs.util.transport.Transport: Connecting Transport0 05-28 16:35:00.742 16913-16986/smt4v.paquete.samba D/jcifs.smb.SmbTransportImpl: Connecting in state 1 addr XX.XX.XXX.X 05-28 16:35:00.782 16913-16986/smt4v.paquete.samba D/jcifs.smb.SmbTransportImpl: Using SMB2 only negotiation 05-28 16:35:00.792 16913-16986/smt4v.paquete.samba V/jcifs.smb.SmbTransportImpl: Wrote negotiate request 05-28 16:35:00.802 16913-16986/smt4v.paquete.samba V/jcifs.smb.SmbTransportImpl: Read negotiate response 05-28 16:35:00.812 16913-16986/smt4v.paquete.samba D/jcifs.smb.SmbTransportImpl: Negotiation response on Transport0 :jcifs.internal.SmbNegotiation@1cab63dd 05-28 16:35:00.812 16913-16986/smt4v.paquete.samba D/jcifs.smb.SmbTransportImpl: Signature negotiation enforced false (server false) enabled false (server true) 05-28 16:35:00.812 16913-16984/smt4v.paquete.samba D/jcifs.smb.SmbTransportImpl: Establishing new session SmbSession[credentials=mydomain\fernan,targetHost=XX.XX.XXX.X,targetDomain=null,uid=0,connectionState=0,usage=1] on Transport0 05-28 16:35:00.852 16913-16984/smt4v.paquete.samba D/jcifs.smb.SmbTransportImpl: Breaking on error command=SMB2_SESSION_SETUP,status=More data is available.,flags=0x0001,mid=1,wordCount=0,byteCount=0 05-28 16:35:01.142 16913-16984/smt4v.paquete.samba D/jcifs.smb.SmbSessionImpl: Context is established 05-28 16:35:01.212 16913-16984/smt4v.paquete.samba D/jcifs.smb.SmbTreeImpl: Disconnect tree on treeConnectFailure jcifs.smb.SmbAuthException: Access is denied. at jcifs.smb.SmbTransportImpl.checkStatus2(SmbTransportImpl.java:1430) at jcifs.smb.SmbTransportImpl.checkStatus(SmbTransportImpl.java:1572) at jcifs.smb.SmbTransportImpl.sendrecv(SmbTransportImpl.java:1027) at jcifs.smb.SmbTransportImpl.send(SmbTransportImpl.java:1543) at jcifs.smb.SmbSessionImpl.send(SmbSessionImpl.java:409) at jcifs.smb.SmbSessionImpl.send(SmbSessionImpl.java:347) at jcifs.smb.SmbTreeImpl.treeConnect(SmbTreeImpl.java:611) at jcifs.smb.SmbTreeConnection.connectTree(SmbTreeConnection.java:614) at jcifs.smb.SmbTreeConnection.connectHost(SmbTreeConnection.java:568) at jcifs.smb.SmbTreeConnection.connectHost(SmbTreeConnection.java:489) at jcifs.smb.SmbTreeConnection.connect(SmbTreeConnection.java:465) at jcifs.smb.SmbTreeConnection.connectWrapException(SmbTreeConnection.java:426) at jcifs.smb.SmbFile.ensureTreeConnected(SmbFile.java:558) at jcifs.smb.SmbFile.exists(SmbFile.java:852) at smt4v.paquete.samba.MainActivity$AsyncCheckOld.doInBackground(MainActivity.java:91) at smt4v.paquete.samba.MainActivity$AsyncCheckOld.doInBackground(MainActivity.java:72) at android.os.AsyncTask$2.call(AsyncTask.java:292) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:818)

mbechler commented 4 years ago

The actual error is the one following: Access is denied. Unfortunately this can mean either that there is a permission issue, there is something in the authentication request (e.g. flags) that the server does not like, or generally a signing related issue. If you have a chance to inspect the server logs that might be the easist way to figure out what is the case.

For the second case you could try setting one the following options:

FerPalos commented 4 years ago

I have set the two option but it doesn't work yet. I couldn't realize yet how to get a readable server logs. It is a windows server 2012 r2 and I have found some traces but not a unique log file as in a linux server. Anyway, doing some test, I have realized if I uncheck the "encrypt data access" box in the server, it is working. So maybe it is related to the SMB3 encryption matter, and it is not supported yet by the library?

mbechler commented 4 years ago

Encryption requirement (which you correctly stated, is not implemented at this point) should not directly cause a failure at this point, but maybe they do something like enforcing SMB >= 3.0 for authenticated connections. You can try setting the jcifs.smb.client.maxVersion to SMB302 or SMB311, and see whether you at least get another error.

Server logs should be in Event Viewer -> Applications and Services Logs -> Microsoft -> Windows -> SMBServer