2011-06-09 57 views
0

当我们尝试在ActiveDirectory中搜索用户时,我们得到该异常 - 0x8007203BSystem.DirectoryServices.DirectoryServicesCOMException(0x8007203B):发生本地错误

基本上,我们部署的Web服务,它使用DirectoryEntry & DirectorySearcher类找到AD用户,而有时这种发生异常。但是当我们做IISReset时,它再次正常工作。

代码是这样的很简单:

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

只有一些次出现这种情况。我没有太多的信息提供,任何猜测大加赞赏

这是我的过滤器看起来像

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; 
} 
+0

向我们展示您如何设置您的DirectorySearcher!你的'过滤器'看起来像什么?你还有什么其他选择? – 2011-06-09 12:40:31

+0

@marc_s,我已经添加了过滤器代码,并且我没有访问他们的安全日志,但正如我提到的那样,但有时连续失败。但IISReset使它再次运作。 – Suresh 2011-06-10 04:50:10

+0

你的.NET框架是什么版本?有两件事你可以尝试:(1)在过滤器中使用'anr ='搜索参数,或者(2)移动到新的System.DirectoryServices.AccountManagement命名空间(需要.NET 3.5或更高版本),这更容易用于搜索 - 不知道它是否会修复错误,但:-( – 2011-06-10 04:53:32

回答

-2

任何猜测都升值呢?

当年这里是我的:

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

是什么让我迷惑的是,你说,它工作的大部分时间......

这篇帮助?

P.S.如果我想到其他东西,我会更新。

+1

cedhost.com链接真的有用吗?他们不是他们之一吐出来的网站吗?页面为每个错误代码出售注册表清洁软件?为什么页面说我有这个错误?! – Rup 2011-06-09 12:49:57

0

你说这只是在一段时间后追加。由于DirectoryEntry和DirectorySearcher构建在一次性类中的COM对象上,因此我会首先添加一些using节以确保基本对象被正确释放。

using(DirectoryEntry root = new DirectoryEntry(ldapPath)) 
{ 
    using(DirectorySearcher searcher=new DirectorySearcher(root)) 
    { 
    ... 
    } 
    ... 
} 
+0

谢谢,处置丢失在我的代码中,我现在将它添加,希望这是原因。 – Suresh 2011-06-11 13:44:21

相关问题