I am using .Net account management libraries to access Active Directory to find information about the current HTTP request user. My application pool works with a custom account, as well as from a single domain. Server and users also belong to the same domain.
public string GetEmployeeId(string SAMAccountName)
{
using (PrincipalContext domainContext = new PrincipalContext(ContextType.Domain))
{
using (UserPrincipal userprincipal = new UserPrincipal(domainContext))
{
userprincipal.SamAccountName = SAMAccountName;
using (PrincipalSearcher ps = new PrincipalSearcher())
{
ps.QueryFilter = userprincipal;
UserPrincipal user = ps.FindOne() as UserPrincipal;
return user.EmployeeId;
}
}
}
}
The setup works fine , but with interruptions, I get below an error from AD.after once it works for the same user without any error .. p>
Is there a way to check the logs / events from AD to find the cause of this error.
System.Runtime.InteropServices.COMException (0x80005000): Unknown error> (0x80005000)