title: Update active directory account properties
body: <p>I'm trying to update some AD accounts using C#. I have:</p>
  
  <pre><code>void UpdateADUser(string emailaddress)
  {
          try
          {
              DirectoryEntry myLdapConnection = createDirectoryEntry();
              DirectorySearcher search = new DirectorySearcher(myLdapConnection);
              search.Filter = "(cn=" + emailaddress + ")";
              search.PropertiesToLoad.Add("title");
              SearchResult result = search.FindOne();
  
              if (result != null)
              {
                 DirectoryEntry entryToUpdate = result.GetDirectoryEntry();
                 Response.Write("Current title   : " +
                                    entryToUpdate.Properties["title"][0].ToString());
              }
  
              else Response.Write("User not found!");
          }
  
          catch (Exception e)
          {
              Response.Write("Exception caught:\n\n" + e.ToString());
          }  
      }
  
      static DirectoryEntry createDirectoryEntry()
      {
          DirectoryEntry ldapConnection = new DirectoryEntry("leasing-vm1.**********.com");
          ldapConnection.Path = "LDAP://OU=leasing options,DC=leasing,DC=local";
          ldapConnection.AuthenticationType = AuthenticationTypes.None;
          ldapConnection.Username = "administrator";
          ldapConnection.Password = "D**********s";
  
          return ldapConnection;
      }  
  </code></pre>
  
  <p>I'm getting an error:</p>
  
  <blockquote>
    <p>The specified domain either does not exist or could not be contacted.</p>
  </blockquote>
  
  <p>Any help appreciated. One potential issue is that my development machine is not part of the domain concerned. Is that the problem?</p>
  
  <p>Thanks</p>