使用 ASP.NET MVC 自动注册的混合表单和 LDAP 身份验证 [英] Mixed Forms and LDAP authentication with auto-registration with ASP.NET MVC

查看:14
本文介绍了使用 ASP.NET MVC 自动注册的混合表单和 LDAP 身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在具有 LDAP(Active Directory)后端(例如 TeamCity)的 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.

所以如果请求的用户有效,我需要先查询 LDAP,然后根据 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 :

用户:

Admin(本地网站用户,仅存储在数据库中)

Admin (local web site user, stored in database only)

某人(LDAP 用户,首次登录时自动在数据库中注册)

Somebody (LDAP user, auto-registered in database on first login)

谢谢.

推荐答案

我有一个大致相似的设置,但我没有在本地注册用户进行表单身份验证.使用 Windows 身份验证时,我可以获得 LDAP 用户信息,然后我使用该信息查询 LDAP(知道用户的 sAMAccountName 和域).

I have a vaguely similar setup but i dont register the users locally for 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).

我认为您希望为表单身份验证配置您的应用,然后让您的登录操作确定是否首先在表单中验证提供的凭据,如果没有,则通过 LDAP 使用一些很好的条件逻辑.

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.

您可以使用此代码示例通过 LDAP 进行身份验证,然后使用相关的用户信息填充您的本地 Forms Membership 数据库.甚至可以将 LDAP DN 与 aspnet Membership 用户一起存储在 db 中,以便进一步调用 LDAP.

You could authenticate over LDAP with this code example and then populate your local Forms Membership db with the relevant user info. Maybe even store the LDAP DN with the aspnet Membership user in the db for further LDAP calls.

这篇关于使用 ASP.NET MVC 自动注册的混合表单和 LDAP 身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆