如何允许Windows身份验证在具有多个域的ASP.NET应用程序MVC4? [英] How do I allow Windows Authentication in ASP.NET MVC4 application with multiple domains?

查看:166
本文介绍了如何允许Windows身份验证在具有多个域的ASP.NET应用程序MVC4?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MVC4应用有关Windows验证两个问题:


  1. 我如何设定,让我可以针对两个Windows域认证?

我所试图做的事:

  [授权(角色= @DOMAINONE \\组名)]
公共类HomeController的:控制器
{
    公众的ActionResult指数()
    {
        返回查看();
    }
    ...
}

和其他域:

  [授权(角色= @DOMAINTWO \\组名)]
公共类StaffController:控制器
{
    公众的ActionResult指数()
    {
        返回查看();
    }
    ...
}


  1. 有没有一种方法,使登录画面的形式在页面上,而不是弹出窗口要求输入用户名/密码?


解决方案

可能是你想看到的Windows和窗体身份验证的组合:有没有一种方法,使登录画面的形式在页面上,而不是弹出窗口要求输入用户名/密码?

如果您在经典模式是 - 你可以有Windows和Forms身份验证。警报会弹出

 挑战和基于登录重定向基础的身份验证,不能使用
同时

但是,您可以忽略此警告。 CarlosAg说:

 我们决定离开那里是因为它仍然是行为,许多用户
方案将被认为不正确的,因为大多数时间形式
身份验证使用匿名身份验证,而不是窗户。

这里

现在,当你想使用Windows身份验证,可以在这里找到解决办法:<一href=\"http://mvolo.com/iis-70-twolevel-authentication-with-forms-authentication-and-windows-authentication/\" rel=\"nofollow\">http://mvolo.com/iis-70-twolevel-authentication-with-forms-authentication-and-windows-authentication/,这允许改变认证方式为页面。
你可以使用Windows身份验证时,管理此另一种方法是使用code管理用户名:

 字符串用户= Request.ServerVariables [LOGON_USER];

请参考以下链接:的http:// beensoft。 blogspot.in/2008/06/mixing-forms-and-windows-authentication.html ,这给混合窗体和Windows身份验证的方式不同。

Two questions regarding Windows Auth in MVC4 application:

  1. How to I set it up so I can authenticate against two windows domains?

What I am trying to do:

[Authorize(Roles = @"DOMAINONE\Group Name")]
public class HomeController : Controller
{
    public ActionResult Index()
    {
        return View();
    }
    ...
}

And the other domain:

[Authorize(Roles = @"DOMAINTWO\Group Name")]
public class StaffController : Controller
{
    public ActionResult Index()
    {
        return View();
    }
    ...
}

  1. Is there a way to make to login screen an form on a page, rather than the pop-up window asking for a username/password?

解决方案

May be you would like to see the mix of Windows and forms authentication : Is there a way to make to login screen an form on a page, rather than the pop-up window asking for a username/password?

If you're in classic mode - you can have both Windows and Forms authentication. An alert will pop up

Challenge-based and login redirect-based authentication cannot be used 
simultaneously

you can however ignore this warning. CarlosAg says that:

we decided to leave it there was because it is still behavior that many user 
scenarios  would be consider incorrect, since most of the time forms 
authentication  uses anonymous  authentication and not windows.

Read here.

Now when you want to use windows authentication, you may find solution here: http://mvolo.com/iis-70-twolevel-authentication-with-forms-authentication-and-windows-authentication/, which allows to change the authentication way for a page. Another way you can manage this when using windows authentication is to manage usernames using code:

string user = Request.ServerVariables["LOGON_USER"];

Refer this link: http://beensoft.blogspot.in/2008/06/mixing-forms-and-windows-authentication.html , which gives a different way of mixing Forms and Windows authentication.

这篇关于如何允许Windows身份验证在具有多个域的ASP.NET应用程序MVC4?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆