title: Error adding users to roles in ADAM (A constraint violation occurred. (Exception from HRESULT: 0x8007202F)
body: <p>I get the error when trying to add users to a group. </p>
  
  <blockquote>
    <p>A constraint violation occurred. (Exception from HRESULT: 0x8007202F) </p>
  </blockquote>
  
  <pre><code>public string addUserToGroup(string userDN, string groupDN)
  {
      try
      {
          DirectoryEntry de = new DirectoryEntry("LDAP://localhost:389/" + groupDN);
          de.Username = "myUsername";
          de.Password = "myPassword";
          de.Properties["member"].Add(userDN);
          de.CommitChanges();
          de.Close();
          //return true;
          return "yes";
      }
  </code></pre>
  
  <p>I'm not sure if it has something to do with the way I have set-up ADAM since I have used application directory partitions. So I have a DN of <code>CN=sandbox,DC=ITOrg</code> I then have 3 directory partitions like so:</p>
  
  <pre><code>CN=sandbox,CN=testApp1,DC=ITOrg
  CN=sandbox,CN=testApp2,DC=ITOrg  .. etc
  </code></pre>
  
  <p>I have my users stored only in <code>CN=sandbox,DC=ITOrg</code> but I then want to give users access to 1 or more of the partitions so I was trying to add the CN of the user </p>
  
  <pre><code>CN=1@test.com,CN=People,CN=sandbox,DC=ITOrg
  </code></pre>
  
  <p>to this:</p>
  
  <pre><code>CN=Readers,CN=Roles,CN=sandbox,CN=testApp1,DC=ITOrg
  </code></pre>
  
  <p>which does not work. Although the code does work if I add the user to the Role in <code>CN=Readers,CN=Roles,CN=sandbox,DC=ITOrg</code>. So does that mean that I have to store users in every partition? Duplicating data?</p>
  
  <p>Does anyone have any thoughts?</p>