Continuous Unknown Error in Active Directory

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)

+6
2

Microsoft , , , .

0x80005000 ADSI, .

, . , , Process Monitor .

, HIVE UNLOADED (. ) trace shot

, .

Log Name:      Application 
Source:        Microsoft-Windows-User Profiles Service 
Date:          10/26/2009 8:22:13 AM 
Event ID:      1530 
Task Category: None 
Level:         Warning 
Keywords:      Classic 
User:          SYSTEM 
Computer:      SERVERNAME 
Description: 
Windows detected your registry file is still in use by other applications or services. The file will be unloaded now. The applications or services that hold your registry file may not function properly afterwards.  
DETAIL - 
1 user registry handles leaked from \Registry\User\S-1-5-21-1049297961-3057247634-349289542-1004_Classes: 
Process 2428 (\Device\HarddiskVolume1\Windows\System32\dllhost.exe) has opened key \REGISTRY\USER\S-1-5-21-1123456789-3057247634-349289542-1004_CLASSES

https://support.microsoft.com/en-us/help/2287297/a-com-application-may-stop-working-on-windows-server-2008-when-a-user

, , .

0

, :

- : = PrincipalContext (ContextType.Domain, "YOURADDOMAIN" );

-1

All Articles