检查 windows 身份验证,如果 sql table 中的用户,则授予对 mvc 5.0 项目的访问权限

Check windows authentication and if user in sql table, give access to mvc 5.0 project

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

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

每当用户尝试登录此页面时,都应检查 windows 身份验证。一旦通过身份验证,它应该检查用户是否在数据库中。如果是,则应允许访问该网页。

谁能告诉我如何实现这一点。我很难弄明白。

第一步转到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