在 MCV3 (Razor) 中结合域、Exchange 和表单身份验证
我正在开发一个项目,该项目将部署到多个 3d 方服务器 - 从 Windows Server 2008 到 XP 计算机的任何服务器。它需要结合多种用户验证方式——跨内网和外网。我现在需要实施身份验证。
谁能推荐一些好的文章或实践来使用 MVC3 实现 Exchange、域 (Windows) 和表单身份验证(按顺序)的组合?
(如果启用)尝试交换身份验证 =>如果失败或禁用,请尝试 Windows 身份验证(如果启用,则再次尝试) =>如果以上均失败,则显示表单身份验证
不同身份验证方式的所有登录名都将存储在数据库中(以与角色和权限模型链接)。
有人使用依赖注入身份验证提供程序完成此操作吗?因此,您可以在应用程序启动时注入提供程序并确定其优先级。
I'm working on a project that will be deployed to multiple 3d party servers - anything from Windows Server 2008, possibly to XP machines. It will need to incorporate several ways for users to authenticate - across intra and extra net. I'm now at a point that requires authentication implementation.
Can anyone recommend good articles or practices to achieve a combination of Exchange, Domain (Windows) and forms authentication (in that order) using MVC3?
(if enabled) Attempt exchange authentication
=> if failed or disabled, attempt windows authentication (again if enabled)
=> if all above fails, show forms authentication
All logins for different ways to authenticate will be stored in database (to link up with role and permission model).
Has anyone done this using dependency injected authentication provider? So you could inject and prioritize the providers when application starts.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将 LDAP(域和交换使用此)与表单身份验证结合起来。请在此处查看这篇文章:
http://support.microsoft.com/kb/316748
http://msdn.microsoft.com/en-us/library/ff649227.aspx
You can combine LDAP (Domain and exchange use this) with forms authentication. Take a look at this article here:
http://support.microsoft.com/kb/316748
http://msdn.microsoft.com/en-us/library/ff649227.aspx
感谢 Sac 提醒我这个老问题。我们确实有一个满足三种身份验证模式的解决方案:
实现此目的的方法是拥有一个执行身份验证的独立网站。可以使用 web.config 或 IIS 管理器在 Forms 和 Windows 之间切换站点。所有其他网站都配置为使用表单身份验证并采用身份验证站点生成的 cookie。其工作的要求是所有站点都位于同一域名上(例如domainname.com)。所有站点还需要在 web.config 中共享相同的 cookie 名称、域名和验证密钥,例如:
当身份验证站点设置为 windows 时,它还需要知道其进行身份验证的域 - 域名需要是能够针对域控制器进行解析。我们的技巧是根据允许用户的内部列表检查已通过浏览器窗口提示进行身份验证的用户,如果不匹配则拒绝身份验证。您可以通过将上下文 Credential 设置回 null 来实现此目的。这会将用户重定向回登录浏览器提示符。无论是 Forms 还是 Windows,当用户成功进行身份验证时,总会附加一个身份验证 cookie。
当身份验证站点设置为表单时,可以通过根据内部用户列表检查用户名和密码来使用纯表单身份验证,或者可以为内部用户分配域名。在这种情况下,它使用 LDAP 协议执行身份验证,以联系域控制器并使用他们输入的用户名和密码进行身份验证。这有利于混合模式。同样有关于如何通过 LDAP 联系域控制器的示例。
此设置的好处是,只有一个站点(身份验证)需要在 Windows 和 Forms 之间交换,其余站点只需依赖 cookie。将 [Authorize] 属性附加到任何站点上的控制器或操作将在 web.config 中进行查找并重定向到 loginUrl。
如果我忘记提及一些重要的事情,请随时发表评论。
Thanks to Sac for reminding me about this old question. We do have a solution which caters to three authentication modes:
The way to accomplish this is by having a standalone web site that performs authentication. The site can be swapped between Forms and Windows using web.config or IIS Manager. All other websites are configured to use Forms authentication and take a cookie produced by authentication site. The requirement for this to work is that all sites be on the same domain name (example domainname.com). All sites also need to share the same cookie name, domain name and validation key in web.config, example:
When authentication site is set to windows, it also needs to know the domain against which it is authenticating - the domain name needs to be able to resolve against the domain controller. Our trick was to check the user who has authenticated through browser window prompt against internal list of allowed users and reject authentication if it doesn't match. You can do so by setting the context Credential back to null. This will redirect the user back to the login browser prompt. Regardless of Forms or Windows, an authentication cookie is always appended when user successfully authenticates.
When authentication site is set to Forms, it can use pure forms authentication by checking the username and password against internal list of users or the internal user can be assigned a domain name. In this case it performs authentication using LDAP protocol to contact the domain controller and authenticate with username and password they typed in. This facilitates mixed mode. Again there are examples out there on how to contact domain controller via LDAP.
The benefit of this setup is that only one of the sites (authentication) ever has to be swapped between Windows and Forms and the rest of the sites just piggy back on the cookie. Appending [Authorize] attribute to controller or actions on any site will look into in web.config and redirect to the loginUrl.
Feel free to comment if I forgot to mention something important.