[jcifs] New Guy: Probably A Very Common Question

Michael B Allen ioplex at gmail.com
Mon Apr 18 12:05:46 MDT 2011


On Sun, Apr 17, 2011 at 8:02 PM, C.Andy <c.andy at mchsi.com> 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.
>
> I have seen recommendations to use SmbFile("smb://").listFiles(); but when
> implemented I get an smb exception "2302" on the listFiles() call. 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. Maybe this is the
> appropriate way to go about the project but I am lost at this point.
>
> 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.
>
> So, I went brute force. I pulled the IP address of the device trying to scan
> the network (ex 192.168.2.5), 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.
>
> 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.
>
> (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.)
>
> Any specifics that can push me in the right direction would be appreciated!

Hi C.Andy,

The NetBIOS "browse" service is deprecated. And I'm not sure that
there is any replacement for it. There are other "discovery" protocols
like Bonjour used by Apple. But I don't know of anything on the
Windows side. There might be an LDAP search on the global catalog
server that might get you part of the way there like searching for all
Computer accounts that have a lastLogon attribute within some time or
something like that. Of course JCIFS wouldn't help you much with that
because listing "smb://" is just querying the browse service and as
you have discovered this really doesn't work very reliably anymore.

Mike

-- 
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/


More information about the jCIFS mailing list