[jcifs] Troubles with hosts/workgroups enumeration

DrZubr DrZubr at tut.by
Fri Nov 24 17:55:57 GMT 2006


I want to describe my troubles with enumerating hosts/workgroups using
jcifs.

With 1.2.9 release I was testing two methods on different networks (no
domains, simple windows workgroups):

1) new SmbFile("smb://").listFiles()
2) new SmbFile("smb://", new NtlmPasswordAuthentication("", "GUEST", "")).listFiles()

On the network #1 both methods throw

jcifs.smb.SmbAuthException: Logon failure: unknown user name or bad password.
        at jcifs.smb.SmbSession.sessionSetup(SmbSession.java:273)
        at jcifs.smb.SmbSession.send(SmbSession.java:225)
        at jcifs.smb.SmbTree.treeConnect(SmbTree.java:147)
        at jcifs.smb.SmbFile.connect(SmbFile.java:798)
        at jcifs.smb.SmbFile.connect0(SmbFile.java:761)
        at jcifs.smb.SmbFile.doNetEnum(SmbFile.java:1615)
        at jcifs.smb.SmbFile.listFiles(SmbFile.java:1585)
        at jcifs.smb.SmbFile.listFiles(SmbFile.java:1495)

        
Debugging with Pcap showed that changes in SmbSession.java at line 271
from

if( response.isLoggedInAsGuest && "GUEST".equalsIgnoreCase( auth.username ) == false) {
    throw new SmbAuthException( NtStatus.NT_STATUS_LOGON_FAILURE );
}

to

if (response.isLoggedInAsGuest && !("GUEST".equalsIgnoreCase(auth.username) || "".equalsIgnoreCase(auth.username))) {
   throw new SmbAuthException(NtStatus.NT_STATUS_LOGON_FAILURE);
}

solves my problem.

So I was using self-"patched" version of jcifs-1.2.9


But on another network (lets call it network #2; network with WINS
server) there was another strange behavior. Some period of time jcifs
works good, but after some number of listFiles() requests "No more
connections can be made to this remote computer at this time because
there are already as many connections as the computer can accept."
error occurred and disappeared only after computer reboot. So I was
unable to use jcifs on that network to enumerate resources because of
instability.


Testing 1.2.10b release on network #1 both methods throw

jcifs.smb.SmbException: Failed to connect to server
java.net.UnknownHostException: ..__MSBROWSE__.<01>
        at jcifs.netbios.NbtAddress.doNameQuery(NbtAddress.java:308)
        at jcifs.netbios.NbtAddress.getByName(NbtAddress.java:413)
        at jcifs.netbios.NbtAddress.getByName(NbtAddress.java:394)
        at jcifs.smb.SmbFile.getAddress(SmbFile.java:746)
        at jcifs.smb.SmbFile.connect(SmbFile.java:787)
        at jcifs.smb.SmbFile.connect0(SmbFile.java:764)
        at jcifs.smb.SmbFile.doNetEnum(SmbFile.java:1699)
        at jcifs.smb.SmbFile.listFiles(SmbFile.java:1612)
        at jcifs.smb.SmbFile.listFiles(SmbFile.java:1498)

Although nbtstat shows "..__MSBROWSE__.<01>  Group" for the
server-host that is master-browser.


I've already tested 1.2.10 release on network #1. As well as with
1.2.9 I receive

jcifs.smb.SmbAuthException: Logon failure: unknown user name or bad password.
        at jcifs.smb.SmbSession.sessionSetup(SmbSession.java:281)
        at jcifs.smb.SmbSession.send(SmbSession.java:233)
        at jcifs.smb.SmbTree.treeConnect(SmbTree.java:154)
        at jcifs.smb.SmbFile.connect(SmbFile.java:801)
        at jcifs.smb.SmbFile.connect0(SmbFile.java:764)
        at jcifs.smb.SmbFile.doNetEnum(SmbFile.java:1699)
        at jcifs.smb.SmbFile.listFiles(SmbFile.java:1612)
        at jcifs.smb.SmbFile.listFiles(SmbFile.java:1498)

Making "patch" in SmbSession:279
from

if( response.isLoggedInAsGuest && "GUEST".equalsIgnoreCase( auth.username ) == false) {
    throw new SmbAuthException( NtStatus.NT_STATUS_LOGON_FAILURE );
}

to

if (response.isLoggedInAsGuest && !("GUEST".equalsIgnoreCase(auth.username) || "".equalsIgnoreCase(auth.username))) {
   throw new SmbAuthException(NtStatus.NT_STATUS_LOGON_FAILURE);
}

makes 1.2.10 release of jcifs working for me.

So I want to pay your attention to this three lines of code: may be there
is a bug? Or can you supply an explanation to me why standard jcifs
doesn't work for me.


WBR,
DrZubr



More information about the jcifs mailing list