suggestion for libsmbclient feature

Michael B Allen mba2000 at
Sat Jan 29 21:42:17 GMT 2005

On Sat, 29 Jan 2005 12:46:59 +0300
Alexander Vodomerov <alex at> wrote:

>    Hello!
> I'm writing a file scanner that searches shares in SMB network
> ( if it matters).
> I would like to use libsmbclient to scan remote server. However, there
> is a problem, that I cannot solve. Out network is quite large (more than
> 2000 hosts). There is no strong administration, so each user choose
> whatever name for his computer. As a result, there many hosts have the
> same names. To scan them, I've tried to use IP instead of name. It

Just curious, but if the names are the same how do you get distinct IPs?

> works well for the most part of network. However, there are some old
> machines running Win98 and this method doesn't work for them.
> So, if I use only name I can't properly scan machines with the same
> names.

Well the proper solution for this would be for libsmbclient to automatically
retry with different CalledNames. The algorithm used by the JCIFS client [1]

	if (IP specified) {
		CalledName = '*SMBSERVER'
	} else if (hexcode == 0x1D || hexcode == 0x1C) {
		CalledName = '*SMBSERVER'
	} else {
		CalledName = NetBIOS Name [2]

	if (connect(address, CalledName)) {
		return SUCCESS;

	if (CalledName == NetBIOS Name) {
		CalledName = '*SMBSERVER'
	} else if (CalledName == '*SMBSERVER') {
		CalledName = doNodeStatusForNetBIOSName();
	} else {
		return FAILURE;

	goto again


[1] The JCIFS client is very very good at quickly crawling large networks.
There are several crawler examples in the examples directory. The T2Crawler
example uses multiple worker threads feed from one small master list of
URLs. This is great performance enhancement because a simple depth first
search algorithm will result in large numbers of state file attributes.

[2] This might be the DNS name too -- you just can't tell really.

Greedo shoots first? Not in my Star Wars.

More information about the samba-technical mailing list