【问题标题】:jcifs fails to resolve a DFS urljcifs 无法解析 DFS url
【发布时间】:2018-12-06 17:13:39
【问题描述】:

尝试使用 DFS URL 访问 SmbFile 时,jcifs 库失败。但是当我使用 dfsutil 返回的 UNC 时,它可以工作。

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

如果 path 设置为

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

调用失败

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

但是用解析后的名字调用是成功的

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>

那么以下网址适用于path

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

如何设置 jcifs 以正确处理 DFS,即不必通过 dfsutil 翻译 url?

【问题讨论】:

    标签: samba jcifs microsoft-distributed-file-system


    【解决方案1】:

    解决方法是设置 WINS 配置。 IPCONFIG /ALL会显示信息:

    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
    

    then配置项必须设置如下:

    jcifs.netbios.wins=10.10.1.59
    

    或者通过jcifs.Config.setProperty()设置它

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-02-28
      • 2022-12-11
      • 2017-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多