【问题标题】:Check windows authentication and if user in sql table, give access to mvc 5.0 project检查 Windows 身份验证,如果用户在 sql 表中,则授予对 mvc 5.0 项目的访问权限
【发布时间】:2016-02-17 18:50:02
【问题描述】:

总的来说,我对 ASP.net 还是很陌生。有人可以在这里帮助我吗?

这是我的场景。 我有一个 sql 数据库,其中提到了将访问 mvc web 项目的所有用户详细信息。我的开发服务器 url 是 delta.dcy.com

每当用户尝试登录此页面时,它应该检查 Windows 身份验证。一旦通过身份验证,它应该检查用户是否在数据库中。如果是,则应授予对网页的访问权限。

有人可以告诉我如何实现这一点。我很难弄清楚。

【问题讨论】:

    标签: c# asp.net-mvc security authentication windows-authentication


    【解决方案1】:

    第一步进入Web.Config 添加:

    <authentication mode="Windows">
    
    </authentication>
    

    那么你的 SQL 方法在哪里

    [Authorize(Roles = "Managers")]
            public ActionResult CompanySecrets()
            {
                return View();
            }
    
            [Authorize(Users="redmond\\swalther")]
            public ActionResult StephenSecrets()
            {
                return View();
            }
    

    更多信息:http://www.asp.net/mvc/overview/older-versions-1/security/authenticating-users-with-windows-authentication-cs

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-10-07
      • 1970-01-01
      • 1970-01-01
      • 2013-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多