代码之家  ›  专栏  ›  技术社区  ›  Stavr00

jcifs无法解析dfs url

  •  0
  • Stavr00  · 技术社区  · 6 年前

    尝试使用dfs url访问smb文件时,jcifs库失败。但是当我使用 dfsutil 它起作用了。

    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>
    

    那么下面的url适用于 路径

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

    如何设置jcifs以正确处理dfs,即不必通过 DFSUTIL ?

    1 回复  |  直到 6 年前
        1
  •  0
  •   Stavr00    6 年前

    解决方案是设置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()

    推荐文章