7

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)

7
  • support.microsoft.com/en-gb/kb/324433
    – Ashigore
    Mar 28, 2016 at 16:28
  • Thanks for the comment sir. But as i understood this server issue is in 2000 and our version is 2012. Mar 29, 2016 at 0:50
  • 3
    I have the same issue but it doesn't happen rightaway. And once it happens, it stays that way until I manually go an recycle the App Pool.
    – icedek
    Apr 7, 2017 at 23:55
  • I have the same issue as well, Like icedek once it happens, it is stuck until I manually recycle the app pool. Jan 14, 2019 at 13:28
  • @Ashigore support.microsoft.com/en-gb/help/324433 not found
    – Kiquenet
    Oct 26, 2022 at 7:35

2 Answers 2

3

I worked with a Microsoft Engineer for a long time to fix this so hopefully my solution can help others fix their problems.

First off the error code 0x80005000 referrers to an invalid ADSI pathname was passed, which wasn’t particularly helpfully.

We did a lot of tracing which was also not very helpful. Last thing we did was use Process Monitor to trace the Registry.

When the error occurred, I noticed a HIVE UNLOADED result happened (see screenshot) trace shot

Based on this we also found this error appearing in the event log.

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

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

Which seem to fix my problem.

-1

Try to identify what domain server you will use:

Something like: = new PrincipalContext(ContextType.Domain, "YOURADDOMAIN");

1
  • Thanks for the reply sir. My server, app pool and client users all from same domain. This code works, but then sometimes clients receive this error and later it works perfectly for the same clients. I'm thinking this error is from AD side. Mar 29, 2016 at 1:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.