[jcifs] browsing a smaller network using netserverenum2

Michael B Allen mba2000 at ioplex.com
Sat Feb 5 21:26:33 GMT 2005


On Sat, 5 Feb 2005 11:46:26 -0600
"Christopher R. Hertel" <crh at ubiqx.mn.org> wrote:

> Thing is, from the trace it seems that jCIFS is doing the right thing...at
> first.  It does a name lookup on the ..__MSBROWSE__.. name, connects to
> the first one it finds (the only one, in this case), and does the
> SessionSetup/TreeConnect to the IPC$ share.  The next thing it should do
> is issue the NetServerEnum2 with the workgroup flag set to obtain the list
> of workgroups.

Yeah, this is broken but it is specific to Samba.

JCIFS always tries the default creds first (just so that the code is
generic). If no creds are supplied the 'GUEST' credentials are the default.
If that fails (as GUEST usually does) it will check to see if the share is
null meaning it's an IPC$ connection and if it is we try 'NULL' (aka
anonymous) credentials.

This is exactly what is happening -- try GUEST, fails with logon failure,
try NULL, success. But the problem is that Samba 2.2.7 at least returns the
Action field of the NULL SessionSetupAndX response indicating the client is
"Logged in as GUEST". Windows NT 4 does not do this. I do not think
anonymous credentials should yield "Logged in as GUEST".

JCIFS deliberately throws an NT_STATUS_LOGON_FAILURE exception if "Logged in
as GUEST" is on and the username is not "GUEST". Thus the problem.

Normally I always use a properties file with good credentials so I never
came across this before. If you do:

  java -Djcifs.properties=my.prp ListFiles smb://

with valid jcifs.smb.client.{domain,username,password} credentials it will
work because the IPC$ connection will be successfull with those creds. Note
you have to use the properties file to specify the creds because smb://@/
will cause url.getAuthority() to return a non-0 value. The fix for this is
to simply change SmbFile.java:1608 to url.getHost(). I'll apply a fix for
that.

As for the original problem, I suppose I could add a conditional expression
to our infamous GUEST clause to also check to see that auth !=
NtlmPasswordAuthentication.NULL just to get around the Samba problem.

Mike

-- 
IRC - where men are men, women are men, and the boys are FBI agents.


More information about the jcifs mailing list