12

在 MVC4 中,我<authentication mode="Windows"/>在 web.config 中启用并创建了一个自定义角色提供程序,然后它会自动WindowsIdentityRolePrincipal您包装。像魅力一样工作。

您将如何使用 OWIN 和/或 Microsoft.ASPNET.Identity 在 MVC5 中执行此操作?

4

1 回答 1

10

它与在 web.config 中配置或在 IIS 网站上配置的方式类似。

<authentication mode="Windows" />
<authorization>
  <deny users="?" />
</authorization>

以上对于Intranet应用程序来说已经足够了。对于其他场景,例如提供额外的声明转换以及混合身份验证,对于 ASP.NET 应用程序,您可以使用自定义 OWIN 中间件处理程序。

看看这样的例子WindowsPrincipalHandler。您需要在 startup.cs 中注册它,例如app.Use(typeof(WindowsPrincipalHandler))

于 2013-10-20T08:12:39.783 回答