views:

13

answers:

0

I have a function that works perfectly when I attempt to add a user from the same domain into a group of the same domain.

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

What I need to be able to do is add a user from a sub domain to this main domain group. For example:

Main domain: geo.com Sub domain: customer.geo.com

I have a user: Homer Simpson who is a member of the customer.geo.com domain. I want to add this user to a group in the geo.com domain. I am passing the correct full adsPath but always get the non helpful error message:

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.

The error is actually being thrown on the Invoke line, but as I said earlier, if the user is in the same domain, this works perfectly.

Any thoughts or suggestions are greatly appreciated.

Geo...