简体   繁体   English

将Windows身份验证与表单身份验证混合

[英]Mixing Windows Authentication with Forms Authentication

Consider a site used for an intranet which should also be accessible from the internet. 考虑一个用于Intranet的站点,该站点也应该可以从Internet访问。 On the intranet you want to use Windows Authentication and on the internet you want the users to access the site using forms authentication. 在Intranet上,您希望使用Windows身份验证,并且在Internet上您希望用户使用表单身份验证访问该站点。

Is it possible to set up a mixed-mode with these two? 是否可以设置这两种混合模式? I just want to validate that the user is logged in with either of them without using two sites. 我只想验证用户是否使用其中任何一个登录,而不使用两个站点。

You may want to look at a similar question: mixed mode authentication against AD and fallback to the database if it fail with Membership providers 您可能希望查看类似的问题: 针对AD的混合模式身份验证以及如果它与成员资格提供程序失败则回退到数据库

In the answer I posit a solution using a facade. 在答案中,我提出了一个使用立面的解决方案。 I have leveraged this approach to integrate AD on multiple domains, aspnet sql provider and a legacy authentication database with measurable success. 我利用这种方法将AD集成到多个域,aspnet sql提供程序和遗留认证数据库,并取得了可观的成功。

I know of no build-in way of doing this. 我知道没有内置的方法来做到这一点。 But you can use a simple workaround: 但您可以使用一个简单的解决方法:

Choose forms authentication as your primary authentication and map windows authentication to it. 选择表单身份验证作为主要身份验证并将Windows身份验证映射到它。 You can do so in the applications AuthenticateRequest using global.asax or a special http handler or module. 您可以使用global.asax或特殊的http处理程序或模块在应用程序AuthenticateRequest中执行此操作。 Identify your intranet user in this request and set the forms authentication cookie using FormsAuthentication.SetAuthCookie programmatically. 在此请求中标识您的Intranet用户,并以编程方式使用FormsAuthentication.SetAuthCookie设置表单身份验证cookie。

I actually use this for a mixed mode forms and IP-Number authentication, but I think it would work for forms and windows auth too. 我实际上将它用于混合模式表单和IP数字身份验证,但我认为它也适用于表单和Windows身份验证。

By the way: Maybe mixed mode forms and IP-Number authentication is a second solution for your problem. 顺便说一句:也许混合模式表单和IP数字身份验证是您的问题的第二个解决方案。 If your server is part of a DMZ you can detect your Intranet user by the IP number subnet. 如果您的服务器是DMZ的一部分,您可以通过IP号子网检测您的Intranet用户。

Hei, I had seen this page talking about 2 level authentication with IIS7: IIS 7.0 Two-Level Authentication with Forms Authentication and Windows Authentication , and this other that has the same requirements as you: IIS mixed mode authentication for ASP.NET Applications - http://beaucrawford.net/post/IIS-ldquo3bmixed-moderdquo3b-authentication-for-ASPNET-Application.aspx , but I didn't try any, maybe it works for you? 嘿,我看过这个页面谈论IIS7的2级身份验证: 带有表单身份验证和Windows身份验证的IIS 7.0双级身份验证 ,以及与您具有相同要求的另一个:ASP.NET应用程序的IIS混合模式身份验证 - http ://beaucrawford.net/post/IIS-ldquo3bmixed-moderdquo3b-authentication-for-ASPNET-Application.aspx ,但我没试过,也许它适合你? I guess you just have to adapt it for your needs. 我想你只需要根据自己的需要进行调整。

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

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