[jcifs] Anonymous access to samba servers

David Kaelbling dkaelbling at blackducksoftware.com
Mon Nov 1 13:36:23 MDT 2010


I'm having trouble getting anonymous access to Samba servers to work.  I
couldn't find a solution in the archives, so here goes....

I'm using jcifs 1.3.15, Samba 3.0.33-3.29.el5_5.1, and Java 1.6.0_13 on
a Linux box.  The smb.conf is pretty minimal, and is attached.
"smbclient -N //donald/public/ -c 'ls'" works, sending:
    Session Setup AndX Request, User: anonymous

jcifs-1.3.15/examples/List throws SmbAuthException(Logon Failure) from
SmbTransport.checkStatus().  It sends:
    Session Setup AndX Request, NTLMSSP_AUTH, User: ?\GUEST

I tried changing List.java to pass NtlmPasswordAuthentication.ANONYMOUS
in the SmbFile constructor, after which it sends:
    Session Setup AndX Request, User: anonymous; 
    Tree Connect AndX, Path: \\donald\PUBLIC

The server is happy with that -- it returns "Guest: Logged in as GUEST".
But then SmbSession.sessionSetup() throws a fake login failure in line

Is the logic in sessionSetup for state 10 right?  Around like 295 it
forces NTLMSSP if auth is not ("","",""), but at line 329 is rejects
anonymous login if auth.username was not "GUEST".  It seems like there
are two different definitions for ANONYMOUS in use here!

Any clues would be appreciated :-)

  - Thanks

David Kaelbling
Senior Software Engineer
Black Duck Software, Inc.

dkaelbling at blackducksoftware.com
T +1.781.810.2041
F +1.781.891.5145

-------------- next part --------------
	workgroup = BDS
	server string = %h Samba Server
	hosts allow = 127. 192.168. 10.
	security = user
	passdb backend = tdbsam
	load printers = no

	comment = Public Stuff
	path = /u1/tmp
	public = yes
	writable = yes
	printable = no
	browseable = yes
	write list = nobody

More information about the jCIFS mailing list