Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

How to use domain environment authentication ? Support ? #205


User avatar
0
liaofeng created

hello , I want to use it in domain environment , and use LDAP authentication . Whether it has been supported ? Can provide a sample ?


2 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Actually, it's simple. If you have a solution based on module-zero, then you can add Abp.Zero.Ldap nuget package and enable LDAP using

    Configuration.Modules.ZeroLdap().Enable(typeof(AppLdapAuthenticationSource));
    

    in PreInitialize of your module. This enables it for the application.

    AppLdapAuthenticationSource class is something like that:

    public class AppLdapAuthenticationSource : LdapAuthenticationSource<Tenant, User>
        {
            public AppLdapAuthenticationSource(ILdapSettings settings, IAbpZeroLdapModuleConfig ldapModuleConfig)
                : base(settings, ldapModuleConfig)
            {
            }
        }
    

    Then you should enable and configure it for a tenant (if your app is single-tenant, it's for Default tenant).

    Check <a class="postlink" href="https://github.com/aspnetboilerplate/module-zero/blob/master/src/Abp.Zero.Ldap/Ldap/Configuration/LdapSettingProvider.cs">https://github.com/aspnetboilerplate/mo ... rovider.cs</a> to see all LDAP settings.

    I will prepare LDAP documentation soon.

  • User Avatar
    0
    iyhammad created

    Hello,

    I tried to follow the steps you mentioned above.

    Here is my Core Module Class

    [DependsOn(typeof(AbpZeroCoreModule),typeof(AbpZeroLdapModule))] public class MyCoreModule : AbpModule { public override void PreInitialize() {

            Configuration.MultiTenancy.IsEnabled = false;
            Configuration.Modules.ZeroLdap().Enable(typeof(AppLdapAuthenticationSource));
    
        }
    
        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
            SettingManager settingsManager = IocManager.Resolve&lt;SettingManager&gt;();
    
            settingsManager.ChangeSettingForTenant(1,LdapSettingNames.IsEnabled, "true");
            settingsManager.ChangeSettingForTenant(1,LdapSettingNames.Domain, "dream2.local");
            settingsManager.ChangeSettingForTenant(1,LdapSettingNames.UserName, "iyhammad");
            settingsManager.ChangeSettingForTenant(1,LdapSettingNames.Password, "P@ssw0rd");
            settingsManager.ChangeSettingForTenant(1,LdapSettingNames.ContextType, "");
            settingsManager.ChangeSettingForTenant(1,LdapSettingNames.Container, "");
        }
    }
    

    But I got this error when initializing Abp.AbpException: There is no setting defined with name: Abp.Zero.Ldap.IsEnabled

    I tried to sset the settings for both the default Tenant and the application and I got the same exception.