title: create AD-User in c#
body: <p>I am trying to create a new AD-User with this code:</p>
  
  <pre><code>PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "Domain", "ou=some_ou, dc=Mydomain");
  UserPrincipal user = new UserPrincipal(ctx, account, passwd, true);
  user.GivenName = Givenname;
  user.Surname = Surname;
  user.DisplayName = Displayname;
  user.UserPrincipalName = account + "@Domain";                
  user.Save();
  </code></pre>
  
  <p>The User is created without error. But I also have to set properties like Address etc, so the code continues with:</p>
  
  <pre><code>string distname = user.DistinguishedName;
  DirectoryEntry duser = new DirectoryEntry(distname);
  try
  {
      duser.Properties["company"].Value = "Company";
  }
  catch (Exception e)
  {
  }
  </code></pre>
  
  <p>Now I am getting </p>
  
  <blockquote>
    <p>Error: System.Exception._COMPlusExceptionCode -532459699</p>
  </blockquote>
  
  <p>The string <code>distname</code> shows the correct distinguished name.</p>