Get computers in a workgroup

后端 未结 1 392
栀梦
栀梦 2021-01-12 22:45

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

相关标签:
1条回答
  • 2021-01-12 23:22

    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);
            }
        }
    
    0 讨论(0)
提交回复
热议问题