I'm trying to get the domain controller that the client machine of an ASP.NET
application is connected to using C#
.
The application is an Intranet application that will never be exposed to the Internet and every user using the application must be authenticated through Windows. This therefore means that the user will always be connected to a domain controller in our corporate network.
I've tried using the following code but it is returning the domain controller that the IIS server is connected to:
using System.DirectoryServices;
public static string GetDC()
{
DirectoryEntry Entry = new DirectoryEntry("LDAP://rootDSE");
return Entry.Properties["dnsHostname"].Value.ToString();
}
I've read several other questions on the matter that all seem to produce the IIS servers domain controller.
My question is whether it is possible to obtain the clients connected domain controller and if so, how?