日期:2014-05-18  浏览次数:20890 次

C#如何对AD中的计算机中的安全添加组或成员
请问各位大侠,
C#能否对于AD中的计算机的安全里添加组或成员?
能的话给个方法吧?谢谢!

------解决方案--------------------
DirectoryEntry dom = new DirectoryEntry();

// Find the container (in this case, the Consulting organizational unit) that you 
// wish to add the new group to.
DirectoryEntry ou = dom.Children.Find("OU=Consulting");

// Add the new group Practice Managers.
DirectoryEntry group = ou.Children.Add("CN=Practice Managers", "group");

// Set the samAccountName for the new group.
group.Properties["samAccountName"].Value = "pracmans";

// Commit the new group to the directory.
group.CommitChanges();