[jcifs] New Guy: Probably A Very Common Question

Christopher R. Hertel crh at ubiqx.mn.org
Sun Apr 17 21:00:02 MDT 2011

C.Andy wrote:
> I have used JCIFS to successfully connect to devices through Smb. What I am
> looking for at this point is a Network Browse or Network Scan feature that
> is generic and locates networks shares that are available on a LAN/WAN
> through a router much like Network Neighborhood on a windows platform does.

Welcome to the SMB/CIFS world.  I'm 'fraid there's nothing that comes easy
here, though we (Samba, jCIFS, etc.) have done our best to make it easier
where we can.

The Browse Service was developed originally for OS/2 and then modified for
use with Windows NT.  Unfortunately, the Browse Service was tied to the
NetBIOS API (not a protocol, an API).

When Microsoft added support for "naked transport" (what they call "Direct
Hosted TCP transport), they replaced the NetBIOS naming system with DNS.
They did not, however, come up with a good replacement for the Browse
Service.  I have not done a lot of digging into this, so the rest of this is
guesswork and hearsay:
- I recall at one point that there was something called MS-CLDAP that was
  in use.  I never grasped if/how it was supposed to work to augment the
  Browse Service for service location and annoucement.
- One person told me that there was a way to use the DNS records from
  Microsoft's DDNS system to figure out where the servers were located.
  I never looked into this so I can't tell you.
- I also remember someone talking about SLP.

...and that's all I know at this point.

> I have seen recommendations to use SmbFile("smb://").listFiles(); but when
> implemented I get an smb exception "2302" on the listFiles() call.

Can you let me know what that number represents?

> Also, it
> is my understanding that this method accesses the Master Browse file which
> is more or less deprecated so the usefulness of this method across
> uncontrolled/unknown networks seems like a bad idea.

The Master Browser is a server, not a file.  The workings of the Browse
Service are described in excessive and painful detail here:

> Maybe this is the
> appropriate way to go about the project but I am lost at this point. 

If the networks are connected, even over a WAN, and share a common NBNS
(WINS) service, and if you have Domain Master Browsers defined, you should
be able to get some useful results out of this method.  If, however, the
Workgroups/Domains are disjoint and you don't have defined Domain Master
Browsers then this will be a royal pain.  Same as it ever was.

> I've also seen references to the crawler example files. These files seem to
> work if you already know what the share host IP is. I am looking for a
> solution to "find" the available networks.

Do you want to find Workgroups/Domains?  Servers?  Shares?  Where are you
trying to start?

> So, I went brute force. I pulled the IP address of the device trying to scan
> the network (ex, dropped the last number (192.168.2.) and walk
> a counter up through a loop and try to connect to each ip from 0 to 255.
> This works but unfortunately this takes about 6 sec per iteration on
> average. I was hoping the .exists() would make the iteration quick but it
> seems it always returns "true" even though there are only currently 3
> devices on the network. 

Then use nmap as a first pass.  :)

> I apologize for asking something so trivial in advance. I am sure there is a
> piece of the puzzle I do not have and would appreciate the fill in.

Well...  Unfortunately there are several pieces to this puzzle and it helps
to have a keen grasp on each.

Perhaps I'm biased because I've spent a long time studying and working in
this environment.  It's a messy environment.  Microsoft has documented a big
hunk of it, mostly over the last three or so years.  I'm painfully familiar
with some of that documentation.  Still, there's a lot of material and it is
dense.  I don't know if they have documented the MS-CLDAP or other protocols
because I'm not sure that they use them any more.

> (And I did attempt to find the answer to my question through a search. This
> is about the 30th tab on the top of my browser and 3 days worth of research.
> Again, I apologize if you're tired of answering this common question.)

The question is simple, the answer...not so much.

> Any specifics that can push me in the right direction would be appreciated!

Did my best.

> Thank you in advance!


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