在ASP MVC中启动时禁用Windows窗体身份验证

时间:2014-01-15 17:39:10

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

所以我有一个场景,我的团队中的一些开发人员需要进行开发工作,但没有加入我们的域。我们目前在ASP MVC 5应用程序中通过Active Directory使用Windows身份验证。我想要做的基本上是:

#if DEBUG

if (Enviroment.Domain == null)
{
   //Turn off authentication in web.config and allow any user.
}

#endif

然后在我的RoleAuthorize属性中,我将进行类似的检查,如果我检测到他们是域外的用户,则返回true。

当我们将应用程序部署到我们的客户端时,他们也将使用Windows身份验证,但在不同的域中。但我有一个配置设置,我改变它以匹配他们的环境。但我们的目标是使用AD来测试那里的环境。我搜遍了谷歌并没有找到满足我需求的解决方案。我能想到的就是使用这些事件来拦截和关闭身份验证:

    protected void Application_BeginRequest(object sender, EventArgs e)
    {
    }

    protected void Application_AuthenticateRequest(object sender, EventArgs e)
    {
    }

0 个答案:

没有答案