ASP.NET 5 / MVC 6 本地 Active Directory
ASP.NET 5 / MVC 6 On-Premises Active Directory
对于早期版本的 .NET 应用程序模板,即 4.5.2,您可以创建一个新的 Web 应用程序,将身份验证更改为 'Work and School Accounts' 并选择 'On-Premises'。在 .NET 5 Web 应用程序模板中,'Work and School Accounts' 选项没有 'On-Premises' 选项。
您如何使用 ASP.NET Identity 通过 .NET 5 中的本地 Active Directory (LDAP) 进行身份验证。明确地说,我不是在寻找 Windows 身份验证,我想让用户输入他们的凭据并处理针对本地 AD 的身份验证。 IOW,用户不需要登录到 windows 机器,他们可以从他们的移动设备等访问
我搜索了几个小时都没有结果,但如果答案就在某处,我也不会感到惊讶。感谢您的帮助!
我不知道任何模板或任何东西,但我按照本指南使用 oAuth2 和 Owin 设置了我自己的身份提供者。
然后为了根据活动目录进行身份验证,我创建了自己的用户存储和用户管理器,并使用 Directory.Masnagement 程序集中的 UserPrincipal 和 PrinipalContext 类 手动完成。
LDAP 和本地身份验证不是一回事,这就是为什么恕我直言,本地模式已作为 "out-of-the-box" 选项消失的原因 - 也因为 Microsoft 几乎没有推动所有人迁移到 Azure 云:)
本地模式(如您所见here) is a way to use AD as a Federation provider (check this on SF),如 Twitter 或 Facebook,如果您愿意;您可以在本地(如果您的 AD 支持)或在云端(使用 Azure)使用 ADFS。
如果您正在寻找 LDAP 身份验证,最简单的工作方法是使用 "Individual User Account" 模式(类似于老派的形式身份验证)并使用 AD 作为用户身份验证的真实来源类似的东西(查看 this SO 文章):
using System.Security;
using System.DirectoryServices.AccountManagement;
public struct Credentials
{
public string Username;
public string Password;
}
public class Domain_Authentication
{
public Credentials Credentials;
public string Domain;
public Domain_Authentication(string Username, string Password, string SDomain)
{
Credentials.Username = Username;
Credentials.Password = Password;
Domain = SDomain;
}
public bool IsValid()
{
using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, Domain))
{
// validate the credentials
return pc.ValidateCredentials(Credentials.Username, Credentials.Password);
}
}
}
无论如何,如果您正在使用异构系统,或者如果您更喜欢使用更多的东西 "secure",我建议您使用 OAuth2,它在 MVC 中作为开箱即用的支持6.
更新
如果您想使用 ASP.NET LDAP 身份,您可以创建您的个人自定义存储提供程序,如 here 中完美解释的那样。
这并不难,但实施起来可能会很长。
没有本地选项,因为 .NET Core 在发布时不支持 WS-Fed。即使在旧版本的 .NET 中,权限也没有使用 LDAP,它使用 WS-Fed 与 ADFS 服务器通信。
非常旧的 ASP.NET 版本确实有一个 AD 会员提供程序,但它在安全方面存在问题并且没有出现在 ASP.NET 4.0
中
您可以实现自己的成员资格提供程序,但 .NET Core 没有 LDAP/System.DirectoryService 类 因此您必须从头开始,包括创建一个库来讨论 LDAP通过套接字。
TLDR:你不能。
对于早期版本的 .NET 应用程序模板,即 4.5.2,您可以创建一个新的 Web 应用程序,将身份验证更改为 'Work and School Accounts' 并选择 'On-Premises'。在 .NET 5 Web 应用程序模板中,'Work and School Accounts' 选项没有 'On-Premises' 选项。
您如何使用 ASP.NET Identity 通过 .NET 5 中的本地 Active Directory (LDAP) 进行身份验证。明确地说,我不是在寻找 Windows 身份验证,我想让用户输入他们的凭据并处理针对本地 AD 的身份验证。 IOW,用户不需要登录到 windows 机器,他们可以从他们的移动设备等访问
我搜索了几个小时都没有结果,但如果答案就在某处,我也不会感到惊讶。感谢您的帮助!
我不知道任何模板或任何东西,但我按照本指南使用 oAuth2 和 Owin 设置了我自己的身份提供者。
然后为了根据活动目录进行身份验证,我创建了自己的用户存储和用户管理器,并使用 Directory.Masnagement 程序集中的 UserPrincipal 和 PrinipalContext 类 手动完成。
LDAP 和本地身份验证不是一回事,这就是为什么恕我直言,本地模式已作为 "out-of-the-box" 选项消失的原因 - 也因为 Microsoft 几乎没有推动所有人迁移到 Azure 云:)
本地模式(如您所见here) is a way to use AD as a Federation provider (check this on SF),如 Twitter 或 Facebook,如果您愿意;您可以在本地(如果您的 AD 支持)或在云端(使用 Azure)使用 ADFS。
如果您正在寻找 LDAP 身份验证,最简单的工作方法是使用 "Individual User Account" 模式(类似于老派的形式身份验证)并使用 AD 作为用户身份验证的真实来源类似的东西(查看 this SO 文章):
using System.Security;
using System.DirectoryServices.AccountManagement;
public struct Credentials
{
public string Username;
public string Password;
}
public class Domain_Authentication
{
public Credentials Credentials;
public string Domain;
public Domain_Authentication(string Username, string Password, string SDomain)
{
Credentials.Username = Username;
Credentials.Password = Password;
Domain = SDomain;
}
public bool IsValid()
{
using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, Domain))
{
// validate the credentials
return pc.ValidateCredentials(Credentials.Username, Credentials.Password);
}
}
}
无论如何,如果您正在使用异构系统,或者如果您更喜欢使用更多的东西 "secure",我建议您使用 OAuth2,它在 MVC 中作为开箱即用的支持6.
更新
如果您想使用 ASP.NET LDAP 身份,您可以创建您的个人自定义存储提供程序,如 here 中完美解释的那样。 这并不难,但实施起来可能会很长。
没有本地选项,因为 .NET Core 在发布时不支持 WS-Fed。即使在旧版本的 .NET 中,权限也没有使用 LDAP,它使用 WS-Fed 与 ADFS 服务器通信。
非常旧的 ASP.NET 版本确实有一个 AD 会员提供程序,但它在安全方面存在问题并且没有出现在 ASP.NET 4.0
中您可以实现自己的成员资格提供程序,但 .NET Core 没有 LDAP/System.DirectoryService 类 因此您必须从头开始,包括创建一个库来讨论 LDAP通过套接字。
TLDR:你不能。