2017-07-27 150 views
1

我一直在追逐這個問題一段時間,現在我無法瞭解它的底部。我讀過這裏的其他解決方案(https://identityserver4.readthedocs.iohttps://github.com/IdentityServer/IdentityServer4.Quickstart.UI),但它仍然無法正常工作,所以我試圖將其降低到絕對的基本水平。這不是我所面臨的實際問題,而是產生了非常相同的結果。即我無法使Windows身份驗證正常工作。IdentityServer4&Windows身份驗證

  1. 我克隆https://github.com/IdentityServer/IdentityServer4.Samples
  2. 我修改Quickstarts/7_JavaScriptClient/src/QuickstartIdentityServer/Quickstart/Account/AccountController.cs使WindowsAuthenticationEnabledtrue
  3. 我然後轉到http://localhost:5000/account/login並嘗試使用Windows外部供應商,我得到401

唯一的區別這個簡單的例子,以及我在我的實際系統上看到的是,我在我的真實網站上獲得憑據的挑戰。

調試代碼我從來沒有看到if(HttpContext.User is WindowsPrincipal)成功,因爲它始終是ClaimsPrincipal

有人可以向我解釋我做錯了什麼嗎?

回答

2

您是否在IIS網站上啓用了Windows身份驗證功能?這需要爲您的WindowsPrincipal分配啓用。請注意,Windows身份驗證僅適用於在IIS或IIS Express後運行。

+0

是的,Windows身份驗證在IIS上啓用。我已經用UseIISIntegration運行Kestrel,所以我猜IIS是作爲這個的反向代理。 –

+0

IIS或IIS Express?爲網站或服務器啓用?我問,因爲HttpContext.User是WindowsPrincipal工作正常,所以這很可能是一個環境問題。 –

+1

哇...我爲網站和應用程序啓用了Windows身份驗證,但是當我爲服務器啓用它時,它全部進入生活。謝謝。 –