8

我有两个应用,一个是窗体身份验证,看起来像这样:ASP.NET混合身份验证

<authentication mode="Forms"> 
     <forms loginUrl="~/Login"></forms> 
     </authentication> 

public class LoginController : Controller 
    { 
     public ActionResult Index() 
     { 
      return View(); 
     } 

     public ActionResult LoginCheck() 
     { 

      string username = Request.Form["username"]; 

      FormsAuthentication.RedirectFromLoginPage(username, true); 

      return RedirectToAction("Index", "Home"); 
     } 
    } 

其他应用程序是空的,但使用Windows身份验证:

<authentication mode="Windows" /> 

public class HomeController : Controller 
    { 
     public ActionResult Index() 
     { 
      ViewBag.Title = "Home Page"; 

      return View(); 
     } 
    } 

我是什么试图做的是:

  1. 用户填写他们的用户名和密码的形式authen tication应用和点击提交

  2. 的LoginCheck方法,采用用户名和密码,验证对抗是Windows身份验证

我,希望我得到的Windows身份验证应用程序话说响应的应用程序是这个用户名和密码是正确的,继续或没有他们不工作

我在正确的轨道上我想完成?我的问题是我不知道如何完成第2部分,如果有人能帮助我,那将是惊人的或者指向正确的方向。

+0

为什么需要混合它?如果Web堆栈位于您的域中,并且您有权访问AD,为什么不使用Windows身份验证?如果没有,那为什么要使用windows auth呢? –

+0

混合它,因为我想用一个窗体而不是一个丑陋的对话框。 – user979331

+3

我很确定Windows代码验证发生在您的代码执行之前。您最好使用Forms Authentication并使用ActiveDirectoryMembershipProvider,如[this](https://msdn.microsoft.com/en-us/library/ff650308.aspx)。 –

回答

1

使用集成Windows身份验证(IWA)时,浏览器应使用Windows凭据自动登录到网站。

这里有一些事情你可以检查:

  • 请问您的浏览器支持IWA?
  • 浏览器和网站之间是否有HTTP代理?
  • 您的机器是否登录到您的网站托管的Windows域?
  • IE设置是否指定提示输入凭据? enter image description here

又见答案this question更多的建议。

2

如果您不必为其他原因使用第二个应用程序,我会建议使用其他方式来验证凭据。

例子: https://stackoverflow.com/a/499716/5036838

后的凭据进行验证,你可以使用任何类型的Cookie /认证基础进行。