当我们嵌套了OU';在asp.net c#中的active directory中创建用户时,是否在active directory中创建用户?

当我们嵌套了OU';在asp.net c#中的active directory中创建用户时,是否在active directory中创建用户?,c#,asp.net,active-directory,C#,Asp.net,Active Directory,使用 我正在进行目录编程,我想知道当我们在active directory中创建用户时,在active directory中嵌套OU时,如何为OU提供路径。目录是一个对象树。每个对象OU(容器)、用户(本例中的叶子)都由一个可分辨名称寻址,该名称由一个attribute=value对组成,以其容器的可分辨名称作为后缀。下面的两个屏幕截图向您展示了两个场景,MMC一个和LDAP一个以及所有DNs 在我的例子中,我可以这样在嵌套OU中创建用户: PrincipalContext pc = new

使用


我正在进行目录编程,我想知道当我们在active directory中创建用户时,在active directory中嵌套OU时,如何为OU提供路径。

目录是一个对象树。每个对象OU(容器)、用户(本例中的叶子)都由一个可分辨名称寻址,该名称由一个
attribute=value
对组成,以其容器的可分辨名称作为后缀。下面的两个屏幕截图向您展示了两个场景,MMC一个和LDAP一个以及所有DNs

在我的例子中,我可以这样在嵌套OU中创建用户:

PrincipalContext pc = new PrincipalContext(ContextType.Domain, "me.com", "OU=Menetwork OU=Users OU=IT")

有趣的是,我得到的信息是,路径是向后指定的。谢谢。我花了1个小时试图弄清楚为什么在试图让用户访问嵌套OU时出错。原来我是从父OU开始的,而不是从叶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();