Home  >  Article  >  Backend Development  >  Using C# to operate Windows user groups in WindowAD

Using C# to operate Windows user groups in WindowAD

巴扎黑
巴扎黑Original
2016-12-19 17:34:371425browse

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn