身份验证 SQL + AD 用户
Authentication SQL + AD Users
我需要创建一个 asp.net mvc 应用程序,但它应该有两种身份验证,AD 和来自 table 的用户,身份验证应该使用表单而不是 Windows 综合.
是否有提供程序,或者我需要编写一个自定义的提供程序吗?如果它是自定义的,我该如何开始?
创建接受用户名和密码的登录页面
作为验证的第一步,根据 AD
验证凭据
using (var context = new PrincipalContext(ContextType.Domain, domain, userName, password))
{
return context.ValidateCredentials(userName, password, ContextOptions.Negotiate);
}
如果这一步成功,再写一个DB层的调用来验证你各自Users中User的存在table;如果需要,请在同一步骤执行授权。一些随机代码
// Authenticate the user using Active Directory
if (!AuthenticateUserWithActiveDirectory(userName, password, domain)) return;
// Get user information from database
if (!securityBL.AuthenticateUser(userName)) return;
我需要创建一个 asp.net mvc 应用程序,但它应该有两种身份验证,AD 和来自 table 的用户,身份验证应该使用表单而不是 Windows 综合.
是否有提供程序,或者我需要编写一个自定义的提供程序吗?如果它是自定义的,我该如何开始?
创建接受用户名和密码的登录页面 作为验证的第一步,根据 AD
验证凭据using (var context = new PrincipalContext(ContextType.Domain, domain, userName, password))
{
return context.ValidateCredentials(userName, password, ContextOptions.Negotiate);
}
如果这一步成功,再写一个DB层的调用来验证你各自Users中User的存在table;如果需要,请在同一步骤执行授权。一些随机代码
// Authenticate the user using Active Directory
if (!AuthenticateUserWithActiveDirectory(userName, password, domain)) return;
// Get user information from database
if (!securityBL.AuthenticateUser(userName)) return;