【问题标题】:How to give path to identify OU when we have nested OU's in active directory while creating a user in active directory in asp.net c#?在asp.net c#的活动目录中创建用户时,当我们在活动目录中嵌套了OU时,如何给出识别OU的路径?
【发布时间】:2012-03-02 10:23:46
【问题描述】:

使用

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

我正在从事目录编程,我想知道当我们在 Active Directory 中创建用户时在 Active Directory 中嵌套 OU 时如何为 OU 提供路径。

【问题讨论】:

    标签: c# asp.net active-directory


    【解决方案1】:

    目录是对象树。每个对象 OU(容器)、用户(在您的情况下为叶)都由一个专有名称寻址,该专有名称由一个 attribute=value 对组成,后缀为他的容器的专有名称。以下两个屏幕截图向您展示了两种愿景,一种是 MMC,一种是具有所有 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(); 
    

    【讨论】:

    • 有趣,所以我得到的外卖信息是路径是向后指定的。谢谢。
    • 我花了 1 小时试图弄清楚为什么在尝试让用户进入嵌套 OU 时出现错误。原来我是从父 OU 开始,而不是从叶 OU 开始。救了我!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多