How to get all domain controllers IP Addresses and names within one forest using C#

hello there

check below code if you are interested in getting all Active directory Domain Controllers Names and IP addresses within one forest


Forest obj = System.DirectoryServices.ActiveDirectory.Forest.GetCurrentForest();
DomainCollection collection = obj.Domains;
foreach (Domain domain in collection)
	DomainControllerCollection domainControllers = domain.FindAllDiscoverableDomainControllers();
	foreach (DomainController domainController in domainControllers)
	{	//You can use below properties to get Domain controller IP address and Name
return domainControllerInfo;
Posted in Programming and tagged , , , , , , . Bookmark the permalink. RSS feed for this post. Leave a trackback.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

Swedish Greys - a WordPress theme from Nordic Themepark.