
[英]Setting a User Group with an Array using Active Directory Domain Services VB.net
[英]Adding Active Directory sub domain user to main domain group
当我尝试将来自同一域的用户添加到同一域的组中时,我具有一个功能完美的功能。
Function AddUserToGroup(ByVal strUserDN As String, ByVal strGroupDN As String, ByVal strGRPDC As String, ByVal strUserDC As String) As Boolean
Dim oUser As DirectoryEntry
Dim oGroup As DirectoryEntry
Dim blnStatus As Boolean
Try
oUser = New DirectoryEntry("LDAP://" & strUserDN)
oGroup = New DirectoryEntry("LDAP://" & strGroupDN)
oGroup.Invoke("Add", oUser.Path.ToString)
oGroup.CommitChanges()
blnStatus = True
Catch ex As Exception
//catch error...send email to support
End Try
oUser = Nothing
oGroup = Nothing
Return blnStatus
End Function
我需要做的是将一个子域中的用户添加到该主域组中。 例如:
主域:geo.com子域:customer.geo.com
我有一个用户:Homer Simpson,它是customer.geo.com域的成员。 我想将此用户添加到geo.com域中的组中。 我传递了正确的完整adsPath,但始终收到无用的错误消息:
User: WACUSTDC2/CN=Simpson\, Homer,OU=Geo Test OU,OU=Customers,DC=customer,DC=geo,DC=com
Group: wadc4/CN=QSGEOTESTOU_RW,OU=Permission Groups,OU=Resources,DC=geo,DC=com
Error: Exception has been thrown by the target of an invocation.
该错误实际上是在Invoke行上引发的,但是正如我之前所说,如果用户在同一个域中,则可以完美地工作。
任何想法或建议,不胜感激。
地...
您依赖于IADsGroup.Add方法。 正确的语法是(我认为-我是C#用户):
oGroup.Invoke("Add", new object[] { oUser.Path }
您还需要检查它是否已经是该组的成员,因为如果存在,则会出现错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.