I am getting an intermittent COM Exception \"An operations error occurred (0x80072020)\" (shown below) when I try and query Active Directory using the metho
Granted this is 2 years later, I ran into this and found that the following solved my issue:
using System.Web.Hosting;
...
...
// Code here runs as the logged on user
using (HostingEnvironment.Impersonate()) {
// This code runs as the application pool user
DirectorySearcher searcher ...
}
reference
If you got a error code, "An operations error occurred (0x80072020)", it might mean "Access denied".
public bool foo(String username, String password) {
string ADIPaddress = "[ipaddress]";
ContextOptions options = ContextOptions.Negotiate;
PrincipalContext principalContext = new PrincipalContext(ContextType.Domain, AD_IPaddress, null, options, username, password);
bool isAuthenticated = principalContext.ValidateCredentials(username, password, options);
return isAuthenticated;
}
Reference