I\'m trying to get all domains that are available in the Windows Login dialog (in the Domain dropdown).
I\'ve tried the following code but it only returns the domai
Take a look at this CodeProject article. You'll find a simple code snippet to enumerate domains in the current forest.
Add a reference to System.DirectoryServices.dll
using (var forest = Forest.GetCurrentForest())
{
foreach (Domain domain in forest.Domains)
{
Debug.WriteLine(domain.Name);
domain.Dispose();
}
}