I'm using .Net account management libraries to access Active Directory to search the details of current http request user. My app pool runs with custom account and it also from the same domain. Server and users also belong to 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;
}
}
}
}
Setup works perfectly but intermittently i get below error from AD.after sometime it works for the same user without any error.
Is there any way to check logs / events from the AD side to find the reason for this error.
System.Runtime.InteropServices.COMException (0x80005000): Unknown error >(0x80005000)