System.DirectoryServices.DirectoryServicesCOMException (0x8007203B): A local error has occurred

0

When we try to search for a user in ActiveDirectory, we get that exception - 0x8007203B.

Basically we deployed a web service, which uses DirectoryEntry & DirectorySearcher class to find a user in AD, and sometimes this exception happens. But when we do IISReset, it again works fine.

Code is very simple like this:

DirectoryEntry domainUser = new DirectoryEntry("LDAP://xxx.yyy/dc=xxx,dc=yyy", "domain\user", "pwd", AuthenticationTypes.Secure); 
DirectoryEntry result = new DirectorySearcher(domainUser, filter);

Only some times this happens. I don't have much information to provide, any guess much appreciated

This is how my filter looks like

public static string BuildFilter(DirectoryEntry dirEntry, string userName, string userMail)
{
   try
   {
      string filter = string.Empty;

      if (!string.IsNullOrEmpty(userName) && string.IsNullOrEmpty(userMail))
         filter = string.Format(@"(&(objectClass=user)(samaccounttype=805306368)(|(CN={0})(samaccountname={0})))", userName);
      else if (string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(userMail))
         filter = string.Format(@"(&(objectClass=user)(samaccounttype=805306368)(mail={0}))", userMail);
      else
         filter = string.Format(@"(&(objectClass=user)(samaccounttype=805306368)(|(CN={0})(samaccountname={0})(mail={1})))", userName, userMail);

      return filter;
   }
   catch (Exception ex)
   {
       _logger.Error("BuildUserSearch - Failed to build LDAP search", ex);
   }
   return null;
}
c#
active-directory
directoryservices
asked on Stack Overflow Jun 9, 2011 by Suresh • edited Jun 10, 2011 by marc_s

2 Answers

0

You say that this it's just append after some time. As DirectoryEntry and DirectorySearcher are built on COM object into disposable class I would first just add some using sections to be sure that underlying objects are corectly freed.

using(DirectoryEntry root = new DirectoryEntry(ldapPath))
{
  using(DirectorySearcher searcher=new DirectorySearcher(root))
  {
    ...
  }
  ...
}
answered on Stack Overflow Jun 10, 2011 by JPBlanc
-2

Any guess are appreciated?

Then here's mine:

  1. ASP.NET: DirectoryServicesCOMException [...];
  2. Windows Error Codes: Repair 0x8007203B. How To Repair 0x8007203B.

What makes me confuse is that you say it works most of the time...

Did this help?

P.S. I'll update if I think of anything else.

answered on Stack Overflow Jun 9, 2011 by Will Marcouiller

User contributions licensed under CC BY-SA 3.0