【问题标题】:ASP.NET Boilerplate: Active Directory Ldap Authentication Invalid Username or PasswordASP.NET 样板:Active Directory Ldap 身份验证用户名或密码无效
【发布时间】:2021-10-06 05:06:13
【问题描述】:
我已经设置了一个测试解决方案来试验 Ldap 身份验证。
我已经关注documentation 并查看了this,然后我在核心项目中设置了我的MyLdapAuthenticationSource 以及包Abp.Zero.Ldap 并设置Configuration.Modules.ZeroLdap().UseUserPrincipalNameAsUserName = true;
当我尝试登录时收到无效的用户名或密码消息。
此外,我设置了一个默认的 .NET 5 Microsoft 解决方案,以验证我能够直接连接到 Active Directory 并且它按预期工作。
【问题讨论】:
标签:
active-directory
ldap
aspnetboilerplate
【解决方案1】:
我能够通过更改应用程序和数据库中的 Settings 来解决这个问题,文档中没有详细说明如何更改它们。
第一:
我在EntityFrameworkCore 项目下的种子主机文件夹中定义了一个要添加到数据库DefaultSettingsCreator 的新设置:
AddSettingIfNotExists(LdapSettingNames.IsEnabled, "true", tenantId);
第二:
我在Core项目下的Configuration文件夹的AppSettingProvider中定义了一个新的SettingDefinition:
new SettingDefinition(LdapSettingNames.IsEnabled, "true", scopes: SettingScopes.Application | SettingScopes.Tenant | SettingScopes.User)
希望这对未来的用户有所帮助。