How can I query all accessible computers that are in a particular workgroup?
Asked
Active
Viewed 5,340 times
6
-
1http://www.codeproject.com/KB/IP/ListNetworkComputers.aspx – Sergey Vedernikov Mar 03 '11 at 08:41
-
Hopefully you're wanting a list of machines that are currently in the workgroup (i.e. switched on and on the network) - otherwise there's no answer. – Damien_The_Unbeliever Mar 03 '11 at 09:17
-
1@Damien: yes I meant that, is `available computer` not the correct term for this? (Serious question) – thumbmunkeys Mar 03 '11 at 09:26
-
personally, I found `available` a bit ambiguous. `accessible` would be a stronger word. – Damien_The_Unbeliever Mar 03 '11 at 09:51
1 Answers
8
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);
}
}

Community
- 1
- 1

Atanas Korchev
- 30,562
- 8
- 59
- 93