AgNO3 / jcifs-ng

A cleaned-up and improved version of the jCIFS library
GNU Lesser General Public License v2.1
318 stars 103 forks source link

Unable to connect to windows share using hostname but works with IP address #363

Open harikrishnanmurthy opened 3 weeks ago

harikrishnanmurthy commented 3 weeks ago

Hi, I have a windows share that looks like this: //insurance_share/datadfs

When I try to connect to this windows share using the hostname above, I get a "Failed to connect to server" error. When I inspected the properties of this windows share, under DFS, it has a number of referral paths. When I use the hostname of one of these DFS, then the connection works.

When I did a ping in command line, I could get their IP address and the connection works using IP address.

Am I required to set any property in order to connect to the windows share using the original name (//insurance_share/datadfs) instead of relying on the DFS referral path or IP address? My configuration looks like this:

    Properties jcifsProperties = new Properties();
    jcifsProperties.setProperty("jcifs.smb.client.minVersion", "SMB311"); //tried with 202 also 
    jcifsProperties.setProperty("jcifs.smb.client.maxVersion","SMB311");  // tried with 202 also
    Configuration config = new PropertyConfiguration(jcifsProperties);
    BaseContext baseCxt = new BaseContext(config);
    NtlmPasswordAuthenticator auth = new NtlmPasswordAuthenticator(null, smbShareUser, smbSharePass);
    CIFSContext authed = baseCxt.withCredentials(auth);

Any help would be much appreciated 🙏 P.S: The machine type is windows 2016 server And the version of jcifs-ng I use is 2.1.9

mbechler commented 3 weeks ago

For jcifs's domain DFS lookups to work you need to provide the domain name in NtlmPasswordAuthenticator. That may be the issue.