2016-03-28 22 views
3

我使用.Net帳戶管理庫訪問Active Directory以搜索當前http請求用戶的詳細信息。 我的應用程序池使用自定義帳戶運行,它也來自同一個域。服務器和用戶也屬於同一個域。來自Active Directory的間歇性未知錯誤

public string GetEmployeeId(string SAMAccountName) 
{ 
using (PrincipalContext domainContext = new PrincipalContext(ContextType.Domain)) 
{ 
using (UserPrincipal userprincipal = new UserPrincipal(domainContext)) 
{ 
userprincipal.SamAccountName = SAMAccountName; 
using (PrincipalSearcher ps = new PrincipalSearcher()) 
{ 
ps.QueryFilter = userprincipal; 
UserPrincipal user = ps.FindOne() as UserPrincipal; 
return user.EmployeeId; 
} 
} 
} 
} 

安裝工程完美間歇我得到下面的錯誤從AD.after有時它的工作原理爲相同的用戶沒有任何錯誤

是否有任何方法檢查AD側的日誌/事件以找出此錯誤的原因。

System.Runtime.InteropServices.COMException(0x80005000):未知的錯誤>(0x80005000)

+0

https://support.microsoft.com/en-gb/kb/324433 – Ashigore

+0

感謝您的評論先生。但據我瞭解,這個服務器問題是在2000年,我們的版本是2012年。 –

+0

我有同樣的問題,但它不會立即發生。一旦發生這種情況,它將保持這種狀態,直到我手動回收應用程序池爲止。 – icedek

回答

-1

試圖找出你會用什麼域名服務器:

喜歡的東西: =新PrincipalContext (ContextType.Domain,「YOURADDOMAIN」);

+0

謝謝您的回覆先生。我的服務器,應用程序池和客戶端用戶都來自同一個域。此代碼有效,但有時客戶端會收到此錯誤,並且稍後它對於相同的客戶端完美工作。我想這個錯誤是來自AD方。 –