如何在 ASP.NET Boilerplate 中使用 LDAP(免费启动模板) [英] How to use LDAP in ASP.NET Boilerplate (Free Startup Template)

查看:33
本文介绍了如何在 ASP.NET Boilerplate 中使用 LDAP(免费启动模板)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 Boilerplate 的免费启动模板版本通过 Active Directory 将身份验证集成到我的 .net Core 应用程序中.我按照 documentation 中的说明进行操作,例如安装 Abp.Zero.Ldap 包,创建LdapAuthenticationSource 类,并注入依赖,如:

I would like to integrate authentication via Active Directory in my .net Core app using Free Startup Template version of the Boilerplate. I followed the instruction in the documentation such as installing Abp.Zero.Ldap package, creating LdapAuthenticationSource class, and injecting dependency like:

[DependsOn(typeof(AbpZeroLdapModule))]
public class MyApplicationCoreModule : AbpModule
{
    public override void PreInitialize()
    {
        Configuration.Modules.ZeroLdap().Enable(typeof (MyLdapAuthenticationSource));    
    }

    ...
}

我是否需要使用实现 ILdapSettings 接口的类来定义任何自定义设置?或者创建任何引用 的类或文件这个文件夹?

Do I need to define any custom settings by using a class implementing ILdapSettings interface? Or create any class or files referencing to this folder?

推荐答案

.NET Core 2.0

这些说明可能不起作用,因为 .NET Core 的 LDAP/AD 身份验证扩展尚未实现.

.NET Core 2.0

The instructions may not work, as LDAP / AD auth extension for .NET Core isn't implemented yet.

跟踪此功能:https://github.com/aspnetboilerplate/aspnetboilerplate/issues/2755

通过安装 Abp.Zero.Ldap 包,您已经在引用该模块(移动 此处).

By installing Abp.Zero.Ldap package, you're already referencing that module (moved here).

LDAP/Active Directory > 设置所述:

LdapAuthenticationSource 需要 ILdapSettings 作为构造函数参数.此接口用于获取 LDAP 设置,如域、用户名和密码以连接到 Active Directory.默认实现(LdapSettings 类)从设置管理器获取这些设置.

LdapAuthenticationSource expects ILdapSettings as a constructor argument. This interface is used to get LDAP settings like domain, user name and password to connect to Active Directory. Default implementation (LdapSettings class) gets these settings from the setting manager.

如果您使用设置管理器,那么没问题.您可以使用 设置管理器 API 更改 LDAP 设置.如果需要,您可以向数据库添加初始/种子数据以默认启用 LDAP 身份验证.

If you work with Setting manager, then no problem. You can change LDAP settings using setting manager API. If you want, you can add an initial/seed data to database to enable LDAP auth by default.

因此,您无需创建实现 ILdapSettings 的类.使用设置管理器的好处是它将设置存储在您的数据库中.自定义类用于从其他地方获取它或对其进行硬编码(如果您只是想尝试则很有用,但在生产/git commit 中是一个很大的禁忌).

So, you don't need to create a class that implements ILdapSettings. The benefit of using the Setting Manager is that it stores the settings in your database. A custom class is for getting it from elsewhere or hardcoding it (useful if you just want to try, but a big no-no in production / git commit).

首先,您可以在 DefaultSettingsCreatorLdapSettingNames:

For a start, you can add seed data for your Host in DefaultSettingsCreator with LdapSettingNames:

public void Create()
{
    // ...

    // LDAP
    AddSettingIfNotExists(LdapSettingNames.IsEnabled, "false");
    // AddSettingIfNotExists(LdapSettingNames...
}

这篇关于如何在 ASP.NET Boilerplate 中使用 LDAP(免费启动模板)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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