本文介绍了Active Directory-组问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Heya All,
我在将已经创建的用户添加到组时遇到问题.
查看MS网站,似乎语法正确,它抛出了"未知对象"错误.
Heya All,
I am having trouble adding an already created user to a group.
Looking over the MS sites and it seems I have the syntax right put it is throwing up "Unknown Object" Errors.
Sub AddUserToAGroup(ByVal GroupName As String, ByVal UserCN As String)
Dim dirEntry As New DirectoryEntry
dirEntry.Path = "LDAP://OU=Some_Site,DC=Domain,DC=NET"
dirEntry.Username = sADUsername
dirEntry.Password = sADPassword
If UserExists(UserCN) = True Then
Dim group As DirectoryEntry = dirEntry.Children.Find("CN=" & GroupName, "group")
Dim usr As DirectoryEntry = group.Children.Find("CN=" & UserCN, "user")
If group IsNot "" Then
group.Properties("member").Add(usr.Properties("distinguishedName").Value)
group.CommitChanges()
End If
ElseIf UserExists(UserCN) = False Then
Exit Sub
End If
End Sub
推荐答案
这篇关于Active Directory-组问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!