VB.net-创建用户组? [英] VB.net - Create a user group?
问题描述
我正在尝试使用vb.net创建一个名为Maintenance_app
的用户组.
I'm trying to create a user group named Maintenance_app
using vb.net.
代码是:
Dim dom As New DirectoryEntry()
Dim ou As DirectoryEntry = dom.Children.Find("")
Dim grp As DirectoryEntry = ou.Children.Add("Maintenance_app", "group")
grp.CommitChanges()
我在第二行收到以下错误:
I receive the following error at the second line:
An unknown directory object was requested
我做错了什么?
推荐答案
If you want to work with Active Directory you need to understand the LDAP ADsPath.
在您的情况下:
Dim dom as New DirectoryEntry
Dim ou as DirectoryEntry = dom.Children.Find("OU=yourOU")
Dim grp as DirectoryEntry = ou.Children.Add("CN=Maintenance_app", group")
grp.CommitChanges()
或者,如果您希望该组位于顶层而没有OU,则只需删除第二行并将第三行更改为:
Or if you want the group on top level without an OU then just erase the 2nd line and change the 3rd line to:
Dim grp as DirectoryEntry = dom.Children.Add("CN=Maintenance_app", group")
好像您是Active Directory的新手,这里有些Glossar:
As it seems that you are new to Active Directory here some Glossar:
DN =专有名称
DN = Distinguished Name
CN =通用名称
OU =组织单位
DC =域组件
公式示例:
DN ="CN = Doe \,John,OU = Employees,OU = London,DC = fabrikam,DC = com"
DN = "CN=Doe\, John,OU=Employees,OU=London,DC=fabrikam,DC=com"
Active Directory中的每个单个对象都有其自己的确切DN.
Every single object in an Active Directory has its own exact DN.
这篇关于VB.net-创建用户组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!