0
我試圖確定如何獲取設置爲針對本地ADFS服務器進行身份驗證的MVC應用程序。我正在使用位於the Github Azure Samples處的Azure AD示例,並按照Vittorio Bertocci's blog中所述對其進行了修改,以使用我的應用的RealmId和我的組織的ADFS元數據端點。當我使用IIS Express運行示例時,會調用OWIN中間件,然後重定向到ADFS登錄屏幕。在本地IIS中未調用ADFS OWIN身份驗證
但是,我正在使用的應用程序需要在IIS中運行,因此我試圖在本地IIS中配置示例應用程序。當我在本地IIS中運行示例時,沒有重定向到ADFS,而是返回窗口(Kerberos)標識。我如何確保OWIN中間件由IIS調用?應用程序池以集成v4.0模式運行。
這是我Startup.Auth.cs代碼:
private static string realm = ConfigurationManager.AppSettings["ida:Wtrealm"];
private static string metadata = ConfigurationManager.AppSettings["ida:ADFSMetadata"];
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseWsFederationAuthentication(
new WsFederationAuthenticationOptions
{
Wtrealm = realm,
MetadataAddress = metadata,
Notifications = new WsFederationAuthenticationNotifications
{
AuthenticationFailed = context =>
{
context.HandleResponse();
context.Response.Redirect("Home/Error?message=" + context.Exception.Message);
return Task.FromResult(0);
}
}
});
}
現在,除Windows身份驗證外,我已禁用所有身份驗證模式。這一定是問題所在,因爲當我切換到只啓用匿名時,它看起來像是重定向到ADFS。 – emaia