DirectoryEntry localMachine = new DirectoryEntry("WinNT://" + Environment.MachineName); // DirectoryEntry admGroup = localMachine.Children.Find("Guests", "group"); // DirectoryEntry admGroup = localMachine.Children.Find("administrators", "group"); DirectoryEntry admGroup = localMachine.Children.Find("users", "group"); //DirectoryEntry admGroup = localMachine.Children.Find("TestUser1", "group"); object members = admGroup.Invoke("members", null); foreach (object groupMember in (IEnumerable)members) { DirectoryEntry member = new DirectoryEntry(groupMember); listBox1.Items.Add(member.Name); }
System.DirectoryServices.dll
using (var forest = Forest.GetCurrentForest()) { foreach (Domain domain in forest.Domains) { Debug.WriteLine(domain.Name); domain.Dispose(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)