title: Server is unwilling to process the request when I try to save after remove member in Active Directory C#
body: <p>I am analyzing and modifying a windows application about to sync data to Active Directory.</p>
  
  <p>When I move users to another department in active directory, </p>
  
  <p>I try to remove member in previous department.</p>
  
  <p>And Member.Remove is fine, but when I try to save it, it throws exception like this</p>
  
  <p><code>Server is unwilling to process the request</code></p>
  
  <p>So, nothing was changed. Sadly, I'm a newbie of Active Directory, I don't know how to handle it.</p>
  
  <p>The code is below. Please share your knowledge.</p>
  
  <pre><code>void MoveUser(string ppk, string pk)
  {
     var aduser = adm.GetUser(pk);
     var adde=aduser.GetUnderlyingObject() as DirectoryEntry;
     var pde = adm.FindOU(ppk);
     if (aduser == null || pde == null)
     {
          return;
     }
     adde.MoveTo(pde);
     var pgroup = adm.GetGroup(ppk);
     if (!aduser.IsMemberOf(pgroup))
     {
          var allgroups = adm.GetAllDE(Words.Group);
          foreach (var sg in allgroups)
          {
              var samname = GetSamName(sg);
              var sgroup = adm.GetGroup(samname);
              if (aduser.IsMemberOf(sgroup))
              {
                  sgroup.Members.Remove(aduser);
                  //exception here
                  //message: Server is unwilling to process the request
                  sgroup.Save();
              }
          }
          pgroup.Members.Add(aduser);
          pgroup.Save();
      }
  }
  
  public UserPrincipal GetUser(string sUserName)
  {
      PrincipalContext oPrincipalContext = GetPrincipalContext();
      UserPrincipal oUserPrincipal = UserPrincipal.FindByIdentity(oPrincipalContext, sUserName);
      return oUserPrincipal;
  }
  
  public DirectoryEntry FindOU(string ouName)
  {
      DirectorySearcher ds = new DirectorySearcher(GetRootOu());
      ds.Filter = "(ou=" + ouName + ")";
      try
      {
          return ds.FindOne().GetDirectoryEntry();
      }
      catch (Exception)
      {
          return null;
      }
   }
  
  public GroupPrincipal GetGroup(string sGroupName)
  {
      PrincipalContext oPrincipalContext = GetPrincipalContext();
  
      GroupPrincipal oGroupPrincipal = GroupPrincipal.FindByIdentity(oPrincipalContext, sGroupName);
      return oGroupPrincipal;
  }
  </code></pre>