使用C#操作WindowAD之的Windows用户组

来源:这里教程网 时间:2026-02-21 13:05:19 作者:

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();
}

相关推荐