使用C#操作WindowAD之的Windows用户组
程序员文章站
2022-03-19 21:20:54
...
public void CreateWindowsGroup(String groupName, String groupDesc, int groupCtl) { String ladpRootPath = "LDAP://192.168.213.168/CN=Users,DC=pk1,DC=cctv,DC=com"; DirectoryEntry ladpRoot = new DirectoryEntry(ladpRootPath); ladpRoot.Username = "XXXXX"; ladpRoot.Password = "XXXXX"; DirectoryEntry group = ladpRoot.Children.Add("CN=" + groupName, "group"); group.Properties["sAMAccountName"].Value = groupName; group.Properties["description"].Value = groupDesc; group.Properties["groupType"].Value = groupCtl; group.CommitChanges(); group.Close(); }