2011-06-09 56 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

相關問題