Developping for the translation industry RSS 2.0



 Wednesday, 10 June 2009

This C# snippet lets you enumerate all the domain controllers in the current Active Directory Domain.

using System.DirectoryServices;
using System.DirectoryServices.ActiveDirectory;

public static ArrayList GetDomainControllerNames()
{

ArrayList domainControllerList = new ArrayList();
Domain currentDomain = Domain.GetCurrentDomain();
foreach (DomainController dc in currentDomain.DomainControllers)
{

domainControllerList .Add(dc.Name);

}
return domainControllerList ;

}

Other relevant posts:

How To: Create User Accounts in Active Directory using C#

How to enumerate the Domains in the current Forest in C#

How To: Use Active Directory To Authenticate Users

Wednesday, 10 June 2009 13:07:53 (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
C# | Code Snippet

Navigation
Advertisement
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2017
Stanislas Biron
Sign In
Statistics
Total Posts: 135
This Year: 0
This Month: 0
This Week: 0
Comments: 1
All Content © 2017, Stanislas Biron