Find domain controller
If you don't have Active Directory on your server and need to work with AD data.. (and you are in the same domain)
Add references System.DirectoryServices and System.DirectoryServices.AccountManagement
...
using System.DirectoryServices;
using System.DirectoryServices.AccountManagement;
public string GetDomainController()
{
using (PrincipalContext context = new PrincipalContext(ContextType.Domain))
{
string controller = context.ConnectedServer;
return ("Domain Controller: " + controller);
}
}