Question

I want to get the Active Directory site of a hosting a file given the UNC path. The LDAP tree is kind of big and contains multiple domains and sub-domains. What I was doing was parsing the path and obtaining the machine name. From there, I can get the IP and query AD to get the AD site getting the IP ranges from the subnets. This works OK as long as the target server is just a simple Windows computer with a shared folder.

However, I'm encountering issues with DFS domain based shares. Getting the machine name doesn't work, as what you are getting is the DFS domain controller and the IP can change dynamically depending on the root target it assigns each time. I have no idea how to solve this. I would appreciate any solution either querying Active Directory, getting information from the DFS server somehow, using JCIFS or any other option. Also I would like to know if there's any way we can identify the UNC path belongs to a DFS share. Just to add more complexity, we cannot use the Windows .NET DFS API as the application runs with Java in Linux.

Thanks in advance.

Was it helpful?

Solution

I found a way of resolving this situation. You can get DFS information from Active Directory (via LDAP). If the path is \mydomain.foo.bar\folder1\folder2 then folder1 is the DFS server. You can search for an object of type "FT-Dfs" with that name (folder1 in this case) and then get the attribute remoteServerName from it, to find the actual path. The only limitation, and that caused me some headaches before I realized, it's that you cannot get that attribute if you query Active Directory from a Global Catalog server, you need to query the specific server that contains that object (or follow referrals from the parent forest).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top