2012-06-28 45 views
0

我的任務是將一些c#v4應用程序從一臺服務器遷移到另一臺服務器,並且我遇到了其中一個aspx窗體的問題。userprinciple.FindByIdentity在一臺服務器上成功,但不是另一臺

表單調用一個類來在其代碼後面的文件中搜索AD用戶。它所調用的方法如下。

public UserPrincipal GetADUser(string samAccountName) 
     { 
     try 
     { 
      UserPrincipal user = UserPrincipal.FindByIdentity(AD.domainContext, samAccountName); 
      return user; 
     } 
     catch(Exception ex) 
     { 
      throw new Exception(" Cant perform this operation:-"+ex.Message); 
     } 
    } 

AD.domainContext定義如下

private static PrincipalContext domainContext = new PrincipalContext(ContextType.Domain, ConfigurationHandler._ADDomain);

我的問題是,該方法適用於我的服務器2(VS開發和服務器正在運行,即時通訊遷移的代碼)和在嘗試遷移到的服務器上引發異常。所有服務器相​​同的環境中的Windows Server R2 2K8運行IIS 7.5

正被拋出是

廣東話執行該操作的錯誤:出現 - 一個操作錯誤。

我有一個搜索,發現下面的計算器問題,但沒有人可以解決問題

System.DirectoryServices.AccountManagement.PrincipalContext and Impersonation in a WCF service

Active Directory COM Exception - An operations error occurred (0x80072020)

沒有人有任何想法什麼會導致此錯誤是拋在一個環境而不是任何其他?

我試圖調試代碼,它在VS調試中工作正常,但是當代碼部署到所述服務器時是我遇到問題時。

任何幫助,想法,想法將不勝感激。

如果我忘記包括任何東西,我很樂意詳細說明所提供的任何信息。

在此先感謝

尼古拉斯

回答

1

爲別人誰面臨着類似的問題的解決方案似乎是用戶名和密碼需要提供查詢AD,除非你有用戶impersination在IIS中開啓。

只需ammending我的方法有以下解決問題

private static PrincipalContext domainContext = new PrincipalContext(ContextType.Domain, null,ConfigurationHandler._ADDomain, ConfigurationHandler._ADUser, ConfigurationHandler._ADPassword); 

感謝

尼古拉斯

相關問題