title: Can not set password when create new Active Directory with C#
body: <p>I'm getting stuck with creating Active Directory User with C#</p>
  
  <p>this is my code use to create a new user:</p>
  
  <pre><code>public bool CreateUser(string userName, string password)
          {
              try
              {
                  DirectoryEntry entry = new DirectoryEntry(lDAPConnectionString, aDConnectionUserName, aDConnectionPassword, AuthenticationTypes.Secure);
  
                  // Use the Add method to add a user to an organizational unit.
                  DirectoryEntry user = entry.Children.Add("CN=" + userName, "user");
                  // Set the samAccountName, then commit changes to the directory.
                  user.Properties["samAccountName"].Value = userName;
                  user.Properties["userPrincipalName"].Value = userName + Constants.ADProperties.ADUPNLogonSuffix;
  
                  user.CommitChanges();
  
                  // Set password never expire
                  int NON_EXPIRE_FLAG = 0x10000;
                  int val = (int)user.Properties["userAccountControl"].Value;
                  user.Properties["userAccountControl"].Value = val | NON_EXPIRE_FLAG;
                  user.CommitChanges();
  
                  // Enable User
                  val = (int)user.Properties["userAccountControl"].Value;
                  user.Properties["userAccountControl"].Value = val &amp; ~(int)Constants.ADS_USER_FLAG_ENUM.ADS_UF_ACCOUNTDISABLE;
                  user.CommitChanges();
                  user.RefreshCache();
  
                  // Set password
                  user.UsePropertyCache = true;
                  user.Invoke("SetOption", new object[] { Constants.ADS_USER_FLAG_ENUM.ADS_OPTION_PASSWORD_PORTNUMBER, Constants.ADProperties.ADPort });
                  user.Invoke("SetOption", new object[] { Constants.ADS_USER_FLAG_ENUM.ADS_OPTION_PASSWORD_METHOD, Constants.ADS_USER_FLAG_ENUM.ADS_PASSWORD_ENCODE_CLEAR });
                  user.Properties["LockOutTime"].Value = 0; 
                  user.Invoke("SetPassword", new object[] { password });
  
                  user.CommitChanges();
  
                  return true;
              }
              catch (Exception)
              { 
              }
  
              return false;
          }      
  </code></pre>
  
  <p>And when I use it, it throw an exception : "The server is unwilling to process the request. (Exception from HRESULT: 0x80072035)"
  at line : "user.Invoke("SetPassword", new object[] { password });"</p>
  
  <p>I tried many way but I cannot solve this problem.
  Any help would be appricated.
  Thanks</p>