title: Setting ASP.Net Permissions - Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
body: <p>I have an MVC 4 application that allows a user to change their Active Directory password through a password reset functionality page. I have the following piece of code that sets the new password:</p>
  
  <pre><code> DirectoryEntry de = sr.GetDirectoryEntry();
   de.Invoke("SetPassword", new object[] { newPassword });
   de.Properties["LockOutTime"].Value = 0;
  </code></pre>
  
  <p>Upon trying to submit the form with the new password details I am having the following error written to the application event log:</p>
  
  <pre><code> 0x80070005 (E_ACCESSDENIED))
  </code></pre>
  
  <p>I have set the Identity property of the Application Pool to NetworkService and had thought that this would have resolved the issue of connecting. Is there anything else further I need to ensure so that my ASPNET application can connect to the AD.</p>