当我们尝试在ActiveDirectory中搜索用户时,我们得到该异常 - 0x8007203B
。System.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;
}
向我们展示您如何设置您的DirectorySearcher!你的'过滤器'看起来像什么?你还有什么其他选择? – 2011-06-09 12:40:31
@marc_s,我已经添加了过滤器代码,并且我没有访问他们的安全日志,但正如我提到的那样,但有时连续失败。但IISReset使它再次运作。 – Suresh 2011-06-10 04:50:10
你的.NET框架是什么版本?有两件事你可以尝试:(1)在过滤器中使用'anr ='搜索参数,或者(2)移动到新的System.DirectoryServices.AccountManagement命名空间(需要.NET 3.5或更高版本),这更容易用于搜索 - 不知道它是否会修复错误,但:-( – 2011-06-10 04:53:32