简体   繁体   English

ASP.NET MVC混合模式身份验证

[英]ASP.NET MVC mixed mode authentication

I'm using Visual Studio 2015 with MVC 5 and need to enable both Windows and Forms Authentication for the same app. 我正在使用Visual Studio 2015和MVC 5,并且需要为同一个应用程序启用Windows和Forms身份验证。 I read that one approach is to have two apps: one has Windows Auth enabled; 我读到一种方法是有两个应用程序:一个启用了Windows身份验证; the other has Forms Auth (main app that contains all the pages). 另一个是Forms Auth(包含所有页面的主应用程序)。

If the user is authenticated via the Windows Auth site, their credentials are passed to the Forms Auth site; 如果用户通过Windows Auth站点进行身份验证,则其凭据将传递到Forms Auth站点; otherwise, they'll have to enter their credentials. 否则,他们将不得不输入他们的凭据。

I've been searching for a way to do this. 我一直在寻找一种方法来做到这一点。 Would the Windows Auth app somehow send the person's username only to the Forms Auth app, which would then assume if a name is provided the user is authenticated? Windows Auth应用程序是否会以某种方式仅将此人的用户名发送给Forms Auth应用程序,然后该应用程序会假设提供了用户身份验证的名称?

How would you do this? 你会怎么做? Thanks. 谢谢。

The solution I found, which is quite effective, is to use the OWIN Mixed-Auth library by Mohammad Younes . 我发现的解决方案非常有效,是使用Mohammad YounesOWIN Mixed-Auth库 This will allow your users to log on via either Windows or Forms auth. 这将允许您的用户通过Windows或Forms身份验证登录。 In addition, for Windows, you can customize it so it passes through seamlessly -- the users don't have to provide their credentials; 此外,对于Windows,您可以对其进行自定义,使其无缝传递 - 用户无需提供凭据; the app fetches that from their system. 该应用程序从他们的系统中获取。

I suggest you download a sample from the link above and get it working; 我建议你从上面的链接下载一个样本,让它工作; then apply the changes to your app. 然后将更改应用到您的应用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM