【发布时间】:2015-09-15 20:21:27
【问题描述】:
我有 2 个应用程序,一个是表单身份验证,看起来像这样:
<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();
}
}
我想要做的是:
用户在表单认证申请中填写用户名和密码,点击提交
LoginCheck 方法获取用户名和密码并针对 Windows 身份验证的应用程序进行身份验证
我希望我能从 Windows 身份验证应用程序中得到回复,说是,这个用户名和密码是正确的,继续,否则它们不起作用
我的目标是否正确?我的问题是我不知道如何完成第 2 部分,如果有人可以帮助我,那将是惊人的或指出我正确的方向。
【问题讨论】:
-
为什么需要混音呢?如果 Web 堆栈在您的域中并且您可以访问 AD,为什么不使用 Windows 身份验证?如果不是,那为什么还要使用 windows auth?
-
混合它是因为我想使用表单而不是丑陋的对话框。
-
我很确定 Windows 身份验证发生在您的代码执行之前。您可能最好使用 Forms Authentication 和 ActiveDirectoryMembershipProvider,例如 this。
-
这是您的要求吗:- 应用程序应使用表单身份验证对 windows 用户进行身份验证,以便当前登录的用户不应仅使用其 windows 帐户绑定到登录应用程序。他应该可以使用任何有效的 Windows 帐户登录。
标签: c# asp.net authentication forms-authentication windows-authentication