13 April, 2011
2 Comments
1 category
If you logon to a domain you can get the IP address of the active directory server by executing the following steps:
start > cmd > echo %LOGONSERVER%
You could also try to ping you’re domain:
start > cmd > ping mydomain.local
If you want to determine the domain controller name in C#, use:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.DirectoryServices.AccountManagement; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { using (PrincipalContext context = new PrincipalContext(ContextType.Domain)) { string controller = context.ConnectedServer; Console.WriteLine(string.Format("Domain Controller: {0}", controller)); Console.WriteLine("Press any key to exit."); Console.ReadLine(); } } } }
Result
Tags: Windows; C#
Category: Uncategorized
Thank you!
It gives Only Domain name not the AD server name. Please give the correct information.