本文介绍了在特定于活动目录的OU&中创建新用户如何把manger参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 The following code is creating user in Root of Active Directory.But Now I need to change the code to create User in specific OU inside ou (Ou Name: Consultants) 我尝试过: 以下代码在Root中创建用户Active Directory。 但是现在我需要更改代码以在ou内部特定OU中创建用户(Ou名称:顾问) 我试过这段代码 What I have tried:The following code is creating user in Root of Active Directory.But Now I need to change the code to create User in specific OU inside ou (Ou Name: Consultants)I have tried this codeDirectoryEntry OU1, OU2, OU3, dirEntry, newUser;dirEntry = new DirectoryEntry(sLDAP, sUserName, sPass, AuthenticationTypes.Secure);object nativeObject = dirEntry.NativeObject;OU1 = dirEntry.Children.Find("OU=" + txtCompany.Text + "");OU2 = OU1.Children.Find("OU=" + txtregion.Text + "");OU3 = OU2.Children.Find("OU=" + ouin + "");newUser = OU3.Children.Add("CN=" + USERID, "user");newUser.Properties["samAccountName"].Value = samAccountName ;newUser.CommitChanges();newUser.Properties["givenName"].Value = firstName;newUser.CommitChanges(); 推荐答案 DirectoryEntry dirEntry = new DirectoryEntry("sLDAP, sUserName, sPass, AuthenticationTypes.Secure);dirEntry.Path = "LDAP://OU=Consultants,OU=whatever,DC=domain,DC=com"; 你也不需要到CommitChanges();每次你设置一个属性。你可以等到最后。 这是一篇非常好的文章,我用它作为一个例子当我试图执行相同类型的功能...... 查询和更新有效目录使用C#(C Sharp) [ ^ ] 祝你好运!Also you don't need to "CommitChanges();" everytime you set an attribute. You can wait until the end.This is a really good article that I used for an example when I attempted to perform the same type function...Querying and Updating Active Directory Using C# (C Sharp)[^]Good LUCK! 这篇关于在特定于活动目录的OU&中创建新用户如何把manger参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-10 02:37