Asp.net

IIS 7.5 中的 Windows 身份驗證因信任關係異常而失敗

  • August 2, 2010

我有一個 ASP.Net 2.0 應用程序,它使用集成的 Windows 身份驗證來驗證/授權使用者。該應用程序在 Windows XP/IIS 5.1、Windows Server 2008/IIS 7 和 Windows Vista/IIS 7 上執行良好。當我嘗試在 Windows 7/IIS 7.5 上執行此應用程序時,出現以下異常:The trust relationship between this workstation and the primary domain failed.

堆棧跟踪如下:

[SystemException: The trust relationship between this workstation and the primary domain failed.
]
  System.Security.Principal.NTAccount.TranslateToSids(IdentityReferenceCollection sourceAccounts, Boolean& someFailed) +1085
  System.Security.Principal.NTAccount.Translate(IdentityReferenceCollection sourceAccounts, Type targetType, Boolean forceSuccess) +46
  System.Security.Principal.WindowsPrincipal.IsInRole(String role) +128
  System.Web.Configuration.AuthorizationRule.IsTheUserInAnyRole(StringCollection roles, IPrincipal principal) +229
  System.Web.Configuration.AuthorizationRule.IsUserAllowed(IPrincipal user, String verb) +354
  System.Web.Configuration.AuthorizationRuleCollection.IsUserAllowed(IPrincipal user, String verb) +245
  System.Web.Security.UrlAuthorizationModule.OnEnter(Object source, EventArgs eventArgs) +11153304
  System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
  System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171

web.config 文件包含以下與身份驗證/授權相關的資訊:

<authentication mode="Windows" />
<authorization&gt
 <!--Deny anonymous users--&gt
 <deny users="?"/&gt
 <allow roles="domain\GroupWithAccess"/&gt
 <deny users="*"/&gt
</authorization&gt

我在研究此錯誤時發現的大多數結果都表明該問題與域中的電腦帳戶損壞有關,並將解決方案列為重新加入域。我已經這樣做了,但錯誤仍然出現。“正常”域操作工作正常(訪問 UNC 共享、登錄等)。

出於兼容性原因,此應用程序在 Classic .Net AppPool 中執行。我嘗試將 AppPool 的標識更改為“NetworkService”,但錯誤仍然存在。

任何幫助是極大的讚賞。

在 Windows Server 2008 R2 上遇到同樣的問題後,我終於找到了答案。從這篇文章

在 Windows 2008 R2 伺服器上禁用以下策略,執行 gpupdate /force 並重新啟動伺服器。

“電腦配置\Windows 設置\安全設置\本地策略\安全選項”

域成員:對安全通道數據進行數字加密或簽名(始終)

域成員:對安全通道數據進行數字加密(如果可能)

域成員:對安全通道數據進行數字簽名(如果可能)

我可以確認這也解決了 Windows 7 上的問題。

引用自:https://stackoverflow.com/questions/1260153