[jcifs] enumerating domains with Wins server

Christopher R. Hertel crh at ubiqx.mn.org
Fri Mar 19 01:46:50 GMT 2004

Gary Rambo wrote:
> Greetings!
> I've asked this question before in other forms but I haven't gotten an
> answer.
> To browse the network neighborhood for a domain list using Jcifs, my only
> choice is something like
>         new SmbFile( "smb://" ).listFiles()
> which broadcasts for __MSBROWSE__ and elicits responses from listening PDCs,

Nope.  The __MSBROWSE__ name is registered by Local Master Browsers (LMBs)
on the local LAN.  The relationship between LMBs and PDCs is ...er...
complex.  It took me a few chapters to explain it in my book.  Basically,
though, a PDC will also be the DMB (Domain Master Browser) for the workgroup
*and* the LMB for the local LAN.  Remote subnets will each have their *own*

Mike:  Just an FYI...  On extension that is possible here is that Samba's
       nbns, when running as an NBNS (WINS server) will respond to queries
       for *<1B>.  That means you can get a list of workgroups from a Samba
       NBNS if the __MSBROWSE__ query fails.  Nifty, eh?

       Of course, that *only* works if the server is running Samba.

> selects the first to answer and sends it a NetServerEnum2 request
> specifying SV_TYPE_DOMAIN_ENUM.


> The problem with this, in my view, is that the resulting picture of the
> network neighborhood depends on the PDC that answers first, and its list
> of domains may not be authoritative.

If you s/PDC/LMB then you're absolutely right.  That's how the system was
designed.  Lovely, innit?

> My users typically have WINS servers configured. If I send the
> NetServerEnum2 request for domains directly to the WINS server, odds are
> I'll get a better answer,

Nope.  WINS is part of a separate service.  Except for the asside to Mike,
above, you don't get Browse Lists from a WINS server.  You get the Browse
List from a Browse Server.

The job of the WINS server is to resolve NetBIOS names to the IP addresses
of the systems that registered them.  The Local Master Browser listens for
service announcements, collects them into a list, and delivers them to
clients when asked.  The Browse Service uses the Name Service, but they're
otherwise unrelated.

Now, it's *likely* that the machine that is set up to be the WINS server
will also win the LMB election and become the Local Master for the LAN. 
It's also likely that the administrator will combine all of these services
onto one box, and your WINS server will also be the LMB, DMB, and PDC for
the workgroup.

In any case, collecting the Browse List needs to be done using the Browse

> and I spare the network the broadcast traffic. If I don't get a list of
> domains from the WINS server, I can revert to the method above.
> To send a NetServerEnum2 request to the WINS server, because it is not a
> public class and SmbFile.sendTransaction is not a public method, I need to
> insert a class, such as the one attached, into src/jcifs/smb, and to invoke
> it with
>         new WinsServer( "smb://" ).enumerateDomains()
> Is there some reason this is not recommended practice, or is there a better
> way to accomplish what I'm after?

Start here:

The Browse Service is weird.  I do my best to explain it in that article,
and then I provide more information in my book (it's online, see my
signature or the jCIFS web page).

Chris -)-----

"Implementing CIFS - the Common Internet FileSystem" ISBN: 013047116X
Samba Team -- http://www.samba.org/     -)-----   Christopher R. Hertel
jCIFS Team -- http://jcifs.samba.org/   -)-----   ubiqx development, uninq.
ubiqx Team -- http://www.ubiqx.org/     -)-----   crh at ubiqx.mn.org
OnLineBook -- http://ubiqx.org/cifs/    -)-----   crh at ubiqx.org

More information about the jcifs mailing list