<p>So my goal is to be able to add a user from one Active Directory Domain to another group in a separate Active Directory Domain.</p>

<p>I'd like to do this in C#.  I know there is a System.DirectoryServices namespace with classes to communicate with AD, but I can't find any information on adding users across domains.</p>

<p>In the environment there are two domain controllers with the same parent forest.  There is a transient trust between the 2 domains, let's call them domains A and B.</p>

<p>I'm able to add a user from B to a Domain Local or Universal group inside of domain A with the Active Directory tool.</p>

<p>Does anyone know how I can do this programmatically using C#?</p>

What worked for me when I wrote code to do this a couple years back:
Get a DirectoryEntry for the group to which you want to add a member.
Call Invoke on the group DirectoryEntry passing arguments "Add" as the method name and the
ADsPath
of the member in an array.
Some sample code off the top of my head:
```
```
DirectoryEntry group = new DirectoryEntry(@"LDAP://CN=foo,DC=domainA");
string memberADsPath = @"LDAP://CN=bar,DC=domainB";
group.Invoke("Add", new Object[] {memberADsPath});
```
```