I have the following chunk of code in a .NET web app used to query AD for a user
using (DirectoryEntry de = new DirectoryEntry(ldap))
{
using (DirectorySearcher adSearch = new DirectorySearcher(de))
{
adSearch.Filter = "(&(objectCategory=person)(objectClass=user)(samAccountName=username))";
SearchResult adSearchResult = adSearch.FindOne();
}
}
When I run this, I sometimes get the following error:
System.Runtime.InteropServices.COMException (0x80005000): Unknown error (0x80005000) at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind() at System.DirectoryServices.DirectoryEntry.get_AdsObject() at System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne) at System.DirectoryServices.DirectorySearcher.FindOne()
When this error is being thrown, it errors every time it runs. To correct this, I have to go to the IIS App Pool associated with this web app and recycle it. After recycling, the code works ... for a period of time. Then the error comes back a few hours later.
Additional information to note:
I would greatly appreciate any suggestions on where to look in IIS for a permanent solution. I can't be recycling the app pool every few hours.
Thanks
User contributions licensed under CC BY-SA 3.0