Developping for the translation industry RSS 2.0



 Wednesday, 10 June 2009

This C# snippet lets you enumerate all the domains present in the current Active Directory Forest.

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

public static ArrayList GetDomainNames()
{

ArrayList domainList = new ArrayList();
Forest currentForest = Forest.GetCurrentForest();
DomainCollection myDomains = currentForest.Domains;
foreach (Domain domainItem in myDomains)
{

domainList.Add(domainItem.Name);

}

return domainList;

}

Other relevant posts:

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

How To: set NTFS Permissions using C#

How To: Use Active Directory To Authenticate Users

Wednesday, 10 June 2009 12:57:23 (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
C# | Code Snippet
Comments are closed.

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 2018
Stanislas Biron
Sign In
Statistics
Total Posts: 135
This Year: 0
This Month: 0
This Week: 0
Comments: 1
All Content © 2018, Stanislas Biron