0

When trying to access an SmbFile with a DFS URL, the jcifs library fails. But when I use the UNC returned by dfsutil it works.

NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication( domain, user, pass );
SmbFile folder = new SmbFile(path,auth);

If path is set to

smb://mydomain.example.com/ourdfs/go/to/my/folder

the call fails with

Exception in thread "main" jcifs.smb.SmbException: The network name cannot be found.

But it is successful when invoked with the resolved name

dfsutil diag viewdfspath \\mydomain.example.com\ourdfs\go\to\my\folder

The DFS Path <\\mydomain.example.com\ourdfs\go\to\my\folder> 
resolves to -> <\\someserver.example.com\sharename$\my\folder>

Then the following url works for path

smb://someserver.example.com/sharename$/my/folder

How do I set up jcifs to handle DFS properly i.e. not having to translate urls thru dfsutil?

Stavr00
  • 3,219
  • 1
  • 16
  • 28

1 Answers1

0

The solution is to set the WINS configuration. IPCONFIG /ALL will show the information:

Connection-specific DNS Suffix  . : MYDOMAIN.EXAMPLE.COM
Description . . . . . . . . . . . : Ethernet Connection
Physical Address. . . . . . . . . : DE-AD-BE-EF-F0-0D
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IPv4 Address. . . . . . . . . . . : 10.10.1.42(Preferred)
Subnet Mask . . . . . . . . . . . : 255.0.0.0
Lease Obtained. . . . . . . . . . : December 3, 2018 09:03:04 AM
Lease Expires . . . . . . . . . . : December 9, 2018 09:03:04 AM
Default Gateway . . . . . . . . . : 10.10.1.1
DHCPv4 Class ID . . . . . . . . . : O-mobile
DHCP Server . . . . . . . . . . . : 10.10.11.13
DNS Servers . . . . . . . . . . . : 10.10.4.48
                                    10.10.4.56
Primary WINS Server . . . . . . . : 10.10.1.59
Secondary WINS Server . . . . . . : 10.10.2.58
NetBIOS over Tcpip. . . . . . . . : Enabled

The then configuration item has to be set as follows:

jcifs.netbios.wins=10.10.1.59

or by setting it with jcifs.Config.setProperty()

Stavr00
  • 3,219
  • 1
  • 16
  • 28