If you want to know the workgroup computer name then code will be
var de = new DirectoryEntry("WinNT://" + workgroupName);
foreach (DirectoryEntry c in de.Children)
{
Console.WriteLine(c.Name);
}
If you want to know the list of domain computer name then it will be
var de = new DirectoryEntry("LDAP://" + domainName);
de.Children.SchemaFilter.Add("computer");
foreach (DirectoryEntry c in de.Children)
{
Console.WriteLine(c.Name);
}
Just you need to take reference of System.DirectoryServices component from GAC(framework dll).