RL8*_*L89 4 c# asp.net active-directory
运用
PrincipalContext pc = new PrincipalContext(ContextType.Domain, "me.com", "OU=Menetwork OU=Users OU=IT")
Run Code Online (Sandbox Code Playgroud)
我正在进行目录编程,我想知道如何在Active Directory中创建用户时在Active Directory中嵌套OU时如何为OU提供路径.
JPB*_*anc 10
目录是对象树.每个对象OU(容器),用户(在您的情况下为叶子)由一个可分辨名称寻址,该名称由一个attribute=value以其容器的可分辨名称为后缀的对组成.以下两个屏幕截图显示了两个愿景,MMC one和具有所有DN的LDAP.


在我的例子中,我是如何在嵌套的OU中创建用户的,如下所示:
/* Creating a user
* Retreiving a principal context
*/
PrincipalContext domainContextMonou = new PrincipalContext(ContextType.Domain, "WM2008R2ENT:389", "ou=SousMonou,ou=Monou,dc=dom,dc=fr", "user", "pass");
/* Create a user principal object
*/
UserPrincipal aSlxUser = new slxUser(domainContextMonou, "user3.users", "pass@1w0rd01", true);
/* assign some properties to the user principal
*/
aSlxUser.GivenName = "user3";
aSlxUser.Surname = "users";
/* Force the user to change password at next logon
*/
//aSlxUser.ExpirePasswordNow();
/* save the user to the directory
*/
aSlxUser.Save();
/* set the password to a new value
*/
aSlxUser.SetPassword("test.2013");
aSlxUser.Save();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
24751 次 |
| 最近记录: |