Sporadic Unknown error (0x8005000) when connecting with LDAP

abas 0 Reputation points
2023-10-17T13:47:57.5166667+00:00

I am encountering a sporadic error with the codebase I'm working on, which manifests as an "Unknown Error (0x80005000)". The issue seems to happen only sometimes (once or twice a week), and the current workaround is to restart the site, which is not a sustainable solution. I'm looking to identify the root cause and find a permanent resolution.

System.DirectoryServices.AccountManagement.PrincipalOperationException: Unknown error (0x80005000)
---> System.Runtime.InteropServices.COMException: Unknown error (0x80005000)   
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)   
at System.DirectoryServices.DirectoryEntry.Bind()    
at System.DirectoryServices.DirectoryEntry.get_AdsObject()    
at System.DirectoryServices.PropertyValueCollection.PopulateList()    
at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName)    
at System.DirectoryServices.PropertyCollection.get_Item(String propertyName)    
at System.DirectoryServices.AccountManagement.ADStoreCtx.IsContainer(DirectoryEntry de)    
at System.DirectoryServices.AccountManagement.ADStoreCtx..ctor(DirectoryEntry ctxBase, Boolean ownCtxBase, String username, String password, ContextOptions options)    
at System.DirectoryServices.AccountManagement.PrincipalContext.CreateContextFromDirectoryEntry(DirectoryEntry entry)    
at System.DirectoryServices.AccountManagement.PrincipalContext.DoLDAPDirectoryInit()    
--- End of inner exception stack trace ---    
at System.DirectoryServices.AccountManagement.PrincipalContext.DoLDAPDirectoryInit()    
at System.DirectoryServices.AccountManagement.PrincipalContext.DoDomainInit()    
at System.DirectoryServices.AccountManagement.PrincipalContext.Initialize()    
at System.DirectoryServices.AccountManagement.PrincipalContext.get_ConnectedServer()   

Did some research and found following

  • Might be related to high workload of authentication server. But there seems to be no sign of high Usage and other applications that use the LDAP server have no sign of this error.
  • Incorrect url. I checked the URL, it is correct and uses LDAP://
  • Might occur when accessing invalid attribute. Questioning this, since it works most of the time with the same error. Only errors sometimes (once/twice a week)

Thanks

Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
6,245 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,648 questions
{count} votes