Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get computers in a workgroup

Tags:

c#

How can I query all accessible computers that are in a particular workgroup?

like image 760
thumbmunkeys Avatar asked Mar 03 '11 08:03

thumbmunkeys


1 Answers

You can use the active directory API - check the DirectoryEntry class (don't forget to add reference to System.DirectoryServices.dll).
Here is a short example:

    using (DirectoryEntry workgroup = new DirectoryEntry("WinNT://Workgroup"))
    {
        foreach (DirectoryEntry child in workgroup.Children)
        {
            Console.WriteLine(child.Name);
        }
    }
like image 99
Atanas Korchev Avatar answered Sep 21 '22 01:09

Atanas Korchev