[jcifs] enumerating domains with Wins server

Gary Rambo grambo at aventail.com
Fri Apr 2 17:45:39 GMT 2004


Chris,

Thanks very much for the information; I'm still digesting it. And I've just gotten my copy of your book.

Gary

Christopher R. Hertel wrote:
> 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*
> LMB.
> 
> 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.
> 
> 
> Yep.
> 
> 
>>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
> service.
> 
> 
>>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://10.0.0.73" ).enumerateDomains()
>>
>>Is there some reason this is not recommended practice, or is there a
> 
> better
> 
>>way to accomplish what I'm after?
> 
> 
> Start here:
> http://www.linux-mag.com/cgi-bin/printer.pl?issue=2001-05&article=smb
> 
> 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 -)-----
> 

-- 
Gary Rambo
Aventail Corporation
Secure access for the real world.
www.aventail.com


More information about the jcifs mailing list