Home  >  Article  >  Backend Development  >  Use C# to operate WindowAD to add objects to user groups

Use C# to operate WindowAD to add objects to user groups

巴扎黑
巴扎黑Original
2016-12-19 17:33:021590browse

Suppose there is a user zhangsan located at LADP://192.168.213.168/CN=zhangsan,CN=Users,DC=pk1,DC=cctv,DC=com. Now we want to add this user to LADP:// In the user group 192.168.213.168/CN=PG_GROUP,OU=ORG_PGM,DC=pk1,DC=cctv,DC=com, the

code is as follows:

C# code

String groupPath = "LADP://192.168.213.168/CN=zhangsan,CN=Users,DC=pk1,DC=cctv,DC=com";  
DirectoryEntry group = new DirectoryEntry(groupPath );  
String userPath = "CN=zhangsan,CN=Users,DC=pk1,DC=cctv,DC=com";  
group.Properties["member"].Add(userPath );  
group.CommitChanges();


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