简体   繁体   English

通过ASP.NET MVC自动注册的混合表单和LDAP身份验证

[英]Mixed Forms and LDAP authentication with auto-registration with ASP.NET MVC

I need to use Form-Based authentication on an ASP.NET MVC web site with LDAP (Active Directory) backend like TeamCity for instance. 我需要在ASP.NET MVC网站上使用基于表单的身份验证,例如带有TeamCity之类的LDAP(活动目录)后端。

So i need to query LDAP first if the requested user is valid, then auto-register user in database according to LDAP user authentication infos in order to use mixed authentication : 因此,我需要先查询LDAP(如果请求的用户有效),然后根据LDAP用户身份验证信息在数据库中自动注册用户,以便使用混合身份验证:

Users : 用户数:

Admin (local web site user, stored in database only) 管理员(本地网站用户,仅存储在数据库中)

Somebody (LDAP user, auto-registered in database on first login) 某人(LDAP用户,首次登录时自动在数据库中注册)

Thanks. 谢谢。

I have a vaguely similar setup but i dont register the users locally for Forms auth. 我有一个类似的设置,但是我没有在本地注册用户进行Forms auth。 When using Windows Auth i can get the LDAP user info and then i query LDAP with that info (knowing the user's sAMAccountName and domain). 使用Windows Auth时,我可以获得LDAP用户信息,然后使用该信息查询LDAP(知道用户的sAMAccountName和域)。

I think you would want to configure your app for Forms auth and then have your login action determine if the credentials supplied validated first in forms then if not, over the LDAP with some nice conditional logic. 我认为您可能希望为Forms auth配置您的应用程序,然后让您的登录操作确定是否首先通过LDAP使用一些很好的条件逻辑在表单中验证了提供的凭据,如果没有,则进行了验证。

You could authenticate over LDAP with this code example and then populate your local Forms Membership db with the relevant user info. 您可以使用此代码示例通过LDAP进行身份验证,然后使用相关的用户信息填充本地的Forms Membership数据库。 Maybe even store the LDAP DN with the aspnet Membership user in the db for further LDAP calls. 甚至可以使用aspnet Membership用户将LDAP DN存储在数据库中,以进行进一步的LDAP调用。

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

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