title: Add users to a Security Group in active directory
body: <p><strong>Using any .NET framework</strong></p>
  
  <p>I am able to create security groups, however when I try to add users from within the same domain I get an error.</p>
  
  <p>Using <code>System.DirectoryServices.AccountManagement</code>:</p>
  
  <pre><code>TheGroup = GroupPrincipal.FindByIdentity(SecurityContext, "GROUPNAME")
  TheGroup.Members.Add(SecurityContext, IdentityType.SamAccountName, "username")
  TheGroup.Save()
  </code></pre>
  
  <p>Everything works for creating, and getting an existing group. Also adding the members works but when I try to save the changes made to the group I get this error: </p>
  
  <blockquote>
    <p>Information about the domain could not be retrieved (1355).</p>
  </blockquote>
  
  <p>Now doing it without using <code>DirectoryServices.AccountManagement</code>:</p>
  
  <pre><code>Dim dGroup As DirectoryEntry = GetDirectoryEntry(GroupPath, UserName, Password)
  dGroup.Properties("member").Add(nUser.Path)
  dGroup.CommitChanges()
  dGroup.Close()
  </code></pre>
  
  <p>Again creating/deleting groups this way is working fine, however when I try to add a member that DOES exist to the a created group I get this error: </p>
  
  <blockquote>
    <p>The server is unwilling to process the request. (Exception from HRESULT: 0x80072035)</p>
  </blockquote>
  
  <p><strong>Going onto the server running AD itself and I can add groups and place users in them. I am using the same credentials.</strong></p>