【问题标题】:Windows authentication on ASP.NET Core 5 MVC for AD groups针对 AD 组的 ASP.NET Core 5 MVC 上的 Windows 身份验证
【发布时间】:2021-03-17 10:37:55
【问题描述】:

我想在我的第一个 ASP.NET Core 5.0 MVC 应用程序中配置 Windows 身份验证。只有属于特定组的用户才能访问该应用程序。

最好的解决方案是什么?

【问题讨论】:

    标签: c# asp.net-core .net-core asp.net-core-mvc


    【解决方案1】:

    检查this thread,您可以尝试使用Policy-based authorization 来验证只有来自Active Directory 组的用户才能访问该页面。请确保您已设置正确的 AD 组名称。

    此外,这里有一些关于配置 Windows 身份验证的资源,您可以参考它们:

    Configure Windows Authentication in ASP.NET Core.

    ASP.NET Core Authorize AD Groups through web.config

    【讨论】:

    • 谢谢智,认证授权后如何跳转到首页?
    • 请检查Startup.Configure方法,默认情况下MVC应用会使用默认路由(endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}");),登录成功后会重定向到Home控制器的Index页面。有关 Asp.net Core MVC 路由的更多详细信息,请查看Routing to controller actions in ASP.NET Core
    • 不是这样,因为如果我从一个链接开始。例如 http://my_app.my_domain/My_Controller/Edit/my_id 没有重定向到主页。过去我在 global.asax session_start 中使用了代码 Response.Redirect ("/")。
    猜你喜欢
    • 1970-01-01
    • 2016-04-04
    • 1970-01-01
    • 2014-12-02
    • 2012-05-03
    • 1970-01-01
    • 1970-01-01
    • 2021-05-31
    • 1970-01-01
    相关资源
    最近更新 更多