Trejkaz
2014-11-12 00:12:00 UTC
Hi all.
I wrote a test program which was eventually supposed to time file transfers
with jCIFS so that I could compare it with HTTP clients.
The test program is pretty simple (but as I haven't been able to connect yet,
I'm not confident that it's correct):
import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbFile;
public class TestCifs {
public static void main(String[] args) throws Exception {
String domain = ""; // have tried the actual name too
String user = "<your_user_here>";
String pass = "<your_pass_here>";
String host = "192.168.1.66";
String share = "Shared";
String relativePath = "path/to/100MiB";
//TODO: Figure out if this is a real URL (for escaping)
NtlmPasswordAuthentication auth =
new NtlmPasswordAuthentication(domain, user, pass);
String url = String.format("smb://%s/%s/%s", host, share,
relativePath);
SmbFile smbFile = new SmbFile(url, auth);
smbFile.getInputStream().close();
}
}
When I run this, I get an error:
Exception in thread "main" jcifs.smb.SmbAuthException: Logon failure:
unknown user name or bad password.
at jcifs.smb.SmbTransport.checkStatus(SmbTransport.java:596)
at jcifs.smb.SmbTransport.send(SmbTransport.java:722)
at jcifs.smb.SmbSession.sessionSetup(SmbSession.java:428)
at jcifs.smb.SmbSession.send(SmbSession.java:239)
at jcifs.smb.SmbTree.treeConnect(SmbTree.java:176)
at jcifs.smb.SmbFile.doConnect(SmbFile.java:925)
at jcifs.smb.SmbFile.connect(SmbFile.java:974)
at jcifs.smb.SmbFile.connect0(SmbFile.java:890)
at jcifs.smb.SmbFile.open0(SmbFile.java:992)
at jcifs.smb.SmbFile.open(SmbFile.java:1026)
at jcifs.smb.SmbFileInputStream.<init>(SmbFileInputStream.java:73)
at jcifs.smb.SmbFileInputStream.<init>(SmbFileInputStream.java:65)
at jcifs.smb.SmbFile.getInputStream(SmbFile.java:2867)
at TestCifs.main(TestCifs.java:24)
If I look at the packet dumps, it gets rejected before it even sends the
username or password, so "unknown user name or bad password" is really a
bit misleading. I guess that STATUS_LOGON_FAILURE simply maps to that
message.
I trimmed the packet dump down to just this connection:
https://www.cloudshark.org/captures/3340b558229a
The file server is running on OSX and both Windows and other Mac clients are
happily connecting to it. smbclient has an error connecting but it seems to at
least authenticate successfully before getting some other error. I have dumps
for all of those too, but am significantly less confident that their contents
don't contain my credentials. ;)
I'm kind of at a loss for how to proceed though, at this point. I was hoping
to use jCIFS as an alternative to people having to manually mount the file
shares, but if there are servers it can't connect to...
TX
I wrote a test program which was eventually supposed to time file transfers
with jCIFS so that I could compare it with HTTP clients.
The test program is pretty simple (but as I haven't been able to connect yet,
I'm not confident that it's correct):
import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbFile;
public class TestCifs {
public static void main(String[] args) throws Exception {
String domain = ""; // have tried the actual name too
String user = "<your_user_here>";
String pass = "<your_pass_here>";
String host = "192.168.1.66";
String share = "Shared";
String relativePath = "path/to/100MiB";
//TODO: Figure out if this is a real URL (for escaping)
NtlmPasswordAuthentication auth =
new NtlmPasswordAuthentication(domain, user, pass);
String url = String.format("smb://%s/%s/%s", host, share,
relativePath);
SmbFile smbFile = new SmbFile(url, auth);
smbFile.getInputStream().close();
}
}
When I run this, I get an error:
Exception in thread "main" jcifs.smb.SmbAuthException: Logon failure:
unknown user name or bad password.
at jcifs.smb.SmbTransport.checkStatus(SmbTransport.java:596)
at jcifs.smb.SmbTransport.send(SmbTransport.java:722)
at jcifs.smb.SmbSession.sessionSetup(SmbSession.java:428)
at jcifs.smb.SmbSession.send(SmbSession.java:239)
at jcifs.smb.SmbTree.treeConnect(SmbTree.java:176)
at jcifs.smb.SmbFile.doConnect(SmbFile.java:925)
at jcifs.smb.SmbFile.connect(SmbFile.java:974)
at jcifs.smb.SmbFile.connect0(SmbFile.java:890)
at jcifs.smb.SmbFile.open0(SmbFile.java:992)
at jcifs.smb.SmbFile.open(SmbFile.java:1026)
at jcifs.smb.SmbFileInputStream.<init>(SmbFileInputStream.java:73)
at jcifs.smb.SmbFileInputStream.<init>(SmbFileInputStream.java:65)
at jcifs.smb.SmbFile.getInputStream(SmbFile.java:2867)
at TestCifs.main(TestCifs.java:24)
If I look at the packet dumps, it gets rejected before it even sends the
username or password, so "unknown user name or bad password" is really a
bit misleading. I guess that STATUS_LOGON_FAILURE simply maps to that
message.
I trimmed the packet dump down to just this connection:
https://www.cloudshark.org/captures/3340b558229a
The file server is running on OSX and both Windows and other Mac clients are
happily connecting to it. smbclient has an error connecting but it seems to at
least authenticate successfully before getting some other error. I have dumps
for all of those too, but am significantly less confident that their contents
don't contain my credentials. ;)
I'm kind of at a loss for how to proceed though, at this point. I was hoping
to use jCIFS as an alternative to people having to manually mount the file
shares, but if there are servers it can't connect to...
TX