[jcifs] jcifs problem and wins resolution
Joe Bentley
jbentley at zonelabs.com
Thu Sep 26 22:23:13 EST 2002
> My servlet runs on the SRVGE03 Windows 2000 Server PDC,
> which also happens to be the DMB; IPCONFIG on SRVGE03 states also that
> it is an H-node, and its Wins "client" configuration points to SRVGE02,
> another
> Windows 2000 Server DC running the Wins server service.
>
> In conclusion:
> I have the \01\02__MSBROWSE__\02<01> entry in my Wins Server
> but even if I don't query the Wins Server:
> I have the \01\02__MSBROWSE__\02<01> registered on my network (if I type
> NBTSTAT -n on SRVGE03 I see the entry)
> and I should get this name via Broadcast !
>
> I specified the following properties in my servlet:
> jcifs.Config.setProperty("jcifs.netbios.wins", "192.168.69.6");
> jcifs.Config.setProperty("jcifs.netbios.baddr", "192.168.69.255");
> jcifs.Config.setProperty("jcifs.resolveOrder", "WINS,DNS,BCAST");
>
I've noticed the same problem too. It's because you are executing your code
on the PDC and a host cannot broadcast to it self.
The problem can also be reproduced doing following:
jcifs.Config.setProperty("jcifs.netbios.baddr", "127.0.0.1");
If you move your code off the DCs, it should work, providing that the baddr
includes at least one DC. Yeah I know it's a lame work around. Let me know
if you find a better answer.
That reminds me, the global jcifs.Config.setProperty("jcifs.netbios.baddr")
design doesn't work for me. I need to be able to pass a broadcast address
into the SmbFile("smb://") call to locally override the jcifs.netbios.baddr
setting. My jCIFS code is sitting on a gateway machine where I need to
broadcast to separate networks that may have over-lapping domain names.
Currently a single-threaded synchronized block is required to protect the
global baddr value before a broadcast call.
Here's an example:
class CIFSDriver {
public static String getDomainController(String domain,
String broadcastAddress) {
InetAddress baddr;
try {
baddr = InetAddress.getByName(broadcastAddress);
}
catch (UnknownHostException e)
{
baddr = null;
}
try {
return NbtAddress.getByName(domain, 0x1c, null,
baddr).getHostAddress();
}
catch (UnknownHostException e)
{
return null;
}
}
public synchronized static void listDomains(String broadcastAddress)
throws Exception {
String oldAddr = jcifs.Config.getProperty("baddr");
jcifs.Config.setProperty("baddr", broadcastAddress);
SmbFile connection = new SmbFile("smb://");
String[] domains = connection.list();
for (int i = 0; i < domains.length; i++)
System.out.println(domains[i] + ":" +
getDomainController(domains[i],
broadcastAddress));
if (oldAddr != null)
jcifs.Config.setProperty("baddr", oldAddr);
}
public static void main(String[] args) throws Exception {
listDomains("192.168.50.255");
listDomains("115.63.255.255");
}
}
-joe
More information about the jcifs
mailing list