diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpAbpLdapOptionsManager.cs b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpAbpLdapOptionsManager.cs deleted file mode 100644 index e41aed4c19..0000000000 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpAbpLdapOptionsManager.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Threading.Tasks; -using Microsoft.Extensions.Options; -using Volo.Abp.Options; -using Volo.Abp.Settings; - -namespace Volo.Abp.Ldap; - -public class AbpAbpLdapOptionsManager : AbpDynamicOptionsManager -{ - protected ISettingProvider SettingProvider { get; } - - public AbpAbpLdapOptionsManager(IOptionsFactory factory, ISettingProvider settingProvider) - : base(factory) - { - SettingProvider = settingProvider; - } - - protected override async Task OverrideOptionsAsync(string name, AbpLdapOptions options) - { - options.ServerHost = await GetSettingOrDefaultValue(LdapSettingNames.ServerHost, options.ServerHost); - options.ServerPort = await SettingProvider.GetAsync(LdapSettingNames.ServerPort, options.ServerPort); - options.BaseDc = await GetSettingOrDefaultValue(LdapSettingNames.BaseDc, options.BaseDc); - options.UserName = await GetSettingOrDefaultValue(LdapSettingNames.UserName, options.UserName); - options.Password = await GetSettingOrDefaultValue(LdapSettingNames.Password, options.Password); - } - - protected virtual async Task GetSettingOrDefaultValue(string name, string defaultValue) - { - var value = await SettingProvider.GetOrNullAsync(name); - return value.IsNullOrWhiteSpace() ? defaultValue : value; - } -} diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpLdapModule.cs b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpLdapModule.cs index a1b90cdfa6..b22a43db9b 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpLdapModule.cs +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpLdapModule.cs @@ -18,11 +18,6 @@ public class AbpLdapModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { - context.Services.AddAbpDynamicOptions(); - - var configuration = context.Services.GetConfiguration(); - Configure(configuration.GetSection("Ldap")); - Configure(options => { options.FileSets.AddEmbedded(); diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpLdapOptions.cs b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpLdapOptions.cs deleted file mode 100644 index e91e9f32c7..0000000000 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpLdapOptions.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Volo.Abp.Ldap; - -public class AbpLdapOptions -{ - public string ServerHost { get; set; } - - public int ServerPort { get; set; } - - public string BaseDc { get; set; } - - /// - /// BindDN - /// - public string UserName { get; set; } - - /// - ///BindPassword - /// - public string Password { get; set; } -} diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/ILdapSettingProvider.cs b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/ILdapSettingProvider.cs new file mode 100644 index 0000000000..f72b4912e1 --- /dev/null +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/ILdapSettingProvider.cs @@ -0,0 +1,18 @@ +using System.Threading.Tasks; + +namespace Volo.Abp.Ldap; + +public interface ILdapSettingProvider +{ + public Task GetServerHostAsync(); + + public Task GetServerPortAsync(); + + public Task GetBaseDcAsync(); + + public Task GetDomainDcAsync(); + + public Task GetUserNameAsync(); + + public Task GetPasswordAsync(); +} diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapManager.cs b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapManager.cs index 7acdf87d9c..aac86b889c 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapManager.cs +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapManager.cs @@ -2,7 +2,6 @@ using System.Threading.Tasks; using LdapForNet; using LdapForNet.Native; -using Microsoft.Extensions.Options; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Volo.Abp.DependencyInjection; @@ -12,11 +11,11 @@ namespace Volo.Abp.Ldap; public class LdapManager : ILdapManager, ITransientDependency { public ILogger Logger { get; set; } - protected IOptions LdapOptions { get; } + protected ILdapSettingProvider LdapSettingProvider { get; } - public LdapManager(IOptions ldapOptions) + public LdapManager(ILdapSettingProvider ldapSettingProvider) { - LdapOptions = ldapOptions; + LdapSettingProvider = ldapSettingProvider; Logger = NullLogger.Instance; } @@ -52,9 +51,7 @@ public class LdapManager : ILdapManager, ITransientDependency protected virtual async Task ConnectAsync(ILdapConnection ldapConnection) { - await LdapOptions.SetAsync(); - - ldapConnection.Connect(LdapOptions.Value.ServerHost, LdapOptions.Value.ServerPort); + ldapConnection.Connect(await LdapSettingProvider.GetServerHostAsync(), await LdapSettingProvider.GetServerPortAsync()); } protected virtual async Task AuthenticateLdapConnectionAsync(ILdapConnection connection, string username, string password) diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingDefinitionProvider.cs b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingDefinitionProvider.cs new file mode 100644 index 0000000000..2be9684e72 --- /dev/null +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingDefinitionProvider.cs @@ -0,0 +1,55 @@ +using Volo.Abp.Ldap.Localization; +using Volo.Abp.Localization; +using Volo.Abp.Settings; + +namespace Volo.Abp.Ldap; + +public class LdapSettingDefinitionProvider : SettingDefinitionProvider +{ + public override void Define(ISettingDefinitionContext context) + { + context.Add( + new SettingDefinition( + LdapSettingNames.ServerHost, + "", + L("DisplayName:Abp.Ldap.ServerHost"), + L("Description:Abp.Ldap.ServerHost")), + + new SettingDefinition( + LdapSettingNames.ServerPort, + "389", + L("DisplayName:Abp.Ldap.ServerPort"), + L("Description:Abp.Ldap.ServerPort")), + + new SettingDefinition( + LdapSettingNames.BaseDc, + "", + L("DisplayName:Abp.Ldap.BaseDc"), + L("Description:Abp.Ldap.BaseDc")), + + new SettingDefinition( + LdapSettingNames.Domain, + "", + L("DisplayName:Abp.Ldap.Domain"), + L("Description:Abp.Ldap.Domain")), + + new SettingDefinition( + LdapSettingNames.UserName, + "", + L("DisplayName:Abp.Ldap.UserName"), + L("Description:Abp.Ldap.UserName")), + + new SettingDefinition( + LdapSettingNames.Password, + "", + L("DisplayName:Abp.Ldap.Password"), + L("Description:Abp.Ldap.Password"), + isEncrypted: true) + ); + } + + private static LocalizableString L(string name) + { + return LocalizableString.Create(name); + } +} diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingNames.cs b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingNames.cs index 7e793716d1..f728f684af 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingNames.cs +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingNames.cs @@ -8,6 +8,8 @@ public static class LdapSettingNames public const string BaseDc = "Abp.Ldap.BaseDc"; + public const string Domain = "Abp.Ldap.Domain"; + public const string UserName = "Abp.Ldap.UserName"; public const string Password = "Abp.Ldap.Password"; diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingProvider.cs b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingProvider.cs index 1e85e84e22..bbb0c44131 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingProvider.cs +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingProvider.cs @@ -1,49 +1,46 @@ -using Volo.Abp.Ldap.Localization; -using Volo.Abp.Localization; +using System; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; using Volo.Abp.Settings; namespace Volo.Abp.Ldap; -public class LdapSettingProvider : SettingDefinitionProvider +public class LdapSettingProvider : ILdapSettingProvider, ITransientDependency { - public override void Define(ISettingDefinitionContext context) + protected ISettingProvider SettingProvider { get; } + + public LdapSettingProvider(ISettingProvider settingProvider) + { + SettingProvider = settingProvider; + } + + public async Task GetServerHostAsync() + { + return await SettingProvider.GetOrNullAsync(LdapSettingNames.ServerHost); + } + + public async Task GetServerPortAsync() + { + return (await SettingProvider.GetOrNullAsync(LdapSettingNames.ServerPort))?.To() ?? default; + } + + public async Task GetBaseDcAsync() + { + return await SettingProvider.GetOrNullAsync(LdapSettingNames.BaseDc); + } + + public async Task GetDomainDcAsync() + { + return await SettingProvider.GetOrNullAsync(LdapSettingNames.Domain); + } + + public async Task GetUserNameAsync() { - context.Add( - new SettingDefinition( - LdapSettingNames.ServerHost, - "", - L("DisplayName:Abp.Ldap.ServerHost"), - L("Description:Abp.Ldap.ServerHost")), - - new SettingDefinition( - LdapSettingNames.ServerPort, - "389", - L("DisplayName:Abp.Ldap.ServerPort"), - L("Description:Abp.Ldap.ServerPort")), - - new SettingDefinition( - LdapSettingNames.BaseDc, - "", - L("DisplayName:Abp.Ldap.BaseDc"), - L("Description:Abp.Ldap.BaseDc")), - - new SettingDefinition( - LdapSettingNames.UserName, - "", - L("DisplayName:Abp.Ldap.UserName"), - L("Description:Abp.Ldap.UserName")), - - new SettingDefinition( - LdapSettingNames.Password, - "", - L("DisplayName:Abp.Ldap.Password"), - L("Description:Abp.Ldap.Password"), - isEncrypted: true) - ); + return await SettingProvider.GetOrNullAsync(LdapSettingNames.UserName); } - private static LocalizableString L(string name) + public async Task GetPasswordAsync() { - return LocalizableString.Create(name); + return await SettingProvider.GetOrNullAsync(LdapSettingNames.Password); } } diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/ar.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/ar.json index 0fa580a24b..8529f4b79c 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/ar.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/ar.json @@ -7,9 +7,11 @@ "Description:Abp.Ldap.ServerPort": "منفذ الخادم", "DisplayName:Abp.Ldap.BaseDc": "مكون المجال الأساسي", "Description:Abp.Ldap.BaseDc": "مكون المجال الأساسي", + "DisplayName:Abp.Ldap.Domain": "اختصاص", + "Description:Abp.Ldap.Domain": "اختصاص", "DisplayName:Abp.Ldap.UserName": "اسم المستخدم", "Description:Abp.Ldap.UserName": "اسم المستخدم", "DisplayName:Abp.Ldap.Password": "كلمة السر", "Description:Abp.Ldap.Password": "كلمة السر" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/cs.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/cs.json index cce2c852c7..f85b141531 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/cs.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/cs.json @@ -7,9 +7,11 @@ "Description:Abp.Ldap.ServerPort": "Port serveru", "DisplayName:Abp.Ldap.BaseDc": "Komponenta základní domény", "Description:Abp.Ldap.BaseDc": "Komponenta základní domény", + "DisplayName:Abp.Ldap.Domain": "Doména", + "Description:Abp.Ldap.Domain": "Doména", "DisplayName:Abp.Ldap.UserName": "uživatelské jméno", "Description:Abp.Ldap.UserName": "uživatelské jméno", "DisplayName:Abp.Ldap.Password": "Heslo", "Description:Abp.Ldap.Password": "Heslo" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/de-DE.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/de-DE.json index 3d2dbb07da..6af048c3e1 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/de-DE.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/de-DE.json @@ -7,9 +7,11 @@ "Description:Abp.Ldap.ServerPort": "Server-Port", "DisplayName:Abp.Ldap.BaseDc": "Basisdomänenkomponente", "Description:Abp.Ldap.BaseDc": "Basisdomänenkomponente", + "DisplayName:Abp.Ldap.Domain": "Domain", + "Description:Abp.Ldap.Domain": "Domain", "DisplayName:Abp.Ldap.UserName": "Benutzername", "Description:Abp.Ldap.UserName": "Benutzername", "DisplayName:Abp.Ldap.Password": "Passwort", "Description:Abp.Ldap.Password": "Passwort" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/en-GB.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/en-GB.json index e78c9bf746..90cc348196 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/en-GB.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/en-GB.json @@ -7,9 +7,11 @@ "Description:Abp.Ldap.ServerPort": "Server port", "DisplayName:Abp.Ldap.BaseDc": "Base domain component", "Description:Abp.Ldap.BaseDc": "Base domain component", + "DisplayName:Abp.Ldap.Domain": "Domain", + "Description:Abp.Ldap.Domain": "Domain", "DisplayName:Abp.Ldap.UserName": "Username", "Description:Abp.Ldap.UserName": "Username", "DisplayName:Abp.Ldap.Password": "Password", "Description:Abp.Ldap.Password": "Password" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/en.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/en.json index 1d720fc26f..bdab4cc00b 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/en.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/en.json @@ -3,16 +3,14 @@ "texts": { "DisplayName:Abp.Ldap.ServerHost": "Server host", "Description:Abp.Ldap.ServerHost": "Server host", - "DisplayName:Abp.Ldap.ServerPort": "Server port", "Description:Abp.Ldap.ServerPort": "Server port", - "DisplayName:Abp.Ldap.BaseDc": "Base domain component", "Description:Abp.Ldap.BaseDc": "Base domain component", - + "DisplayName:Abp.Ldap.Domain": "Domain", + "Description:Abp.Ldap.Domain": "Domain", "DisplayName:Abp.Ldap.UserName": "Username", "Description:Abp.Ldap.UserName": "Username", - "DisplayName:Abp.Ldap.Password": "Password", "Description:Abp.Ldap.Password": "Password" } diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/es.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/es.json index 65aa1c68b0..6579a43cbd 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/es.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/es.json @@ -7,9 +7,11 @@ "Description:Abp.Ldap.ServerPort": "Puerto del servidor", "DisplayName:Abp.Ldap.BaseDc": "Dominio base", "Description:Abp.Ldap.BaseDc": "Dominio base", + "DisplayName:Abp.Ldap.Domain": "Dominio", + "Description:Abp.Ldap.Domain": "Dominio", "DisplayName:Abp.Ldap.UserName": "Nombre de usuario", "Description:Abp.Ldap.UserName": "Nombre de usuario", "DisplayName:Abp.Ldap.Password": "Contraseña", "Description:Abp.Ldap.Password": "Contraseña" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/fi.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/fi.json index 953f4491db..83a2cacd03 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/fi.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/fi.json @@ -7,9 +7,11 @@ "Description:Abp.Ldap.ServerPort": "Palvelimen portti", "DisplayName:Abp.Ldap.BaseDc": "Perustoimialueen komponentti", "Description:Abp.Ldap.BaseDc": "Perustoimialueen komponentti", + "DisplayName:Abp.Ldap.Domain": "Verkkotunnus", + "Description:Abp.Ldap.Domain": "Verkkotunnus", "DisplayName:Abp.Ldap.UserName": "Käyttäjätunnus", "Description:Abp.Ldap.UserName": "Käyttäjätunnus", "DisplayName:Abp.Ldap.Password": "Salasana", "Description:Abp.Ldap.Password": "Salasana" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/fr.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/fr.json index adcded679d..e23b0fc1be 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/fr.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/fr.json @@ -7,9 +7,11 @@ "Description:Abp.Ldap.ServerPort": "Port de serveur", "DisplayName:Abp.Ldap.BaseDc": "Composant de domaine de base", "Description:Abp.Ldap.BaseDc": "Composant de domaine de base", + "DisplayName:Abp.Ldap.Domain": "Domaine", + "Description:Abp.Ldap.Domain": "Domaine", "DisplayName:Abp.Ldap.UserName": "Nom d'utilisateur", "Description:Abp.Ldap.UserName": "Nom d'utilisateur", "DisplayName:Abp.Ldap.Password": "Mot de passe", "Description:Abp.Ldap.Password": "Mot de passe" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/hi.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/hi.json index b466bdb570..f46516a6f2 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/hi.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/hi.json @@ -7,9 +7,11 @@ "Description:Abp.Ldap.ServerPort": "सर्वर पोर्ट", "DisplayName:Abp.Ldap.BaseDc": "बेस डोमेन घटक", "Description:Abp.Ldap.BaseDc": "बेस डोमेन घटक", + "DisplayName:Abp.Ldap.Domain": "कार्यक्षेत्र", + "Description:Abp.Ldap.Domain": "कार्यक्षेत्र", "DisplayName:Abp.Ldap.UserName": "उपयोगकर्ता नाम", "Description:Abp.Ldap.UserName": "उपयोगकर्ता नाम", "DisplayName:Abp.Ldap.Password": "कुंजिका", "Description:Abp.Ldap.Password": "कुंजिका" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/hu.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/hu.json index 1b240d9b29..f5e023cc77 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/hu.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/hu.json @@ -3,18 +3,15 @@ "texts": { "DisplayName:Abp.Ldap.ServerHost": "Szerver host", "Description:Abp.Ldap.ServerHost": "Az LDAP ksizolgáló szerver hostneve vagy IP címe", - "DisplayName:Abp.Ldap.ServerPort": "Szerver port", "Description:Abp.Ldap.ServerPort": "LDAP kommunikáció portja", - "DisplayName:Abp.Ldap.BaseDc": "Bázis tartomány-komponens", "Description:Abp.Ldap.BaseDc": "Bázis tartomány-komponens", - + "DisplayName:Abp.Ldap.Domain": "Tartomány", + "Description:Abp.Ldap.Domain": "Tartomány", "DisplayName:Abp.Ldap.UserName": "Felhasználónév", "Description:Abp.Ldap.UserName": "Felhasználónév", - "DisplayName:Abp.Ldap.Password": "Jelszó", "Description:Abp.Ldap.Password": "Jelszó" } } - \ No newline at end of file diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/is.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/is.json index 038755d966..ffca0ac122 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/is.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/is.json @@ -7,9 +7,11 @@ "Description:Abp.Ldap.ServerPort": "Server port", "DisplayName:Abp.Ldap.BaseDc": "Grunn léna hlutur", "Description:Abp.Ldap.BaseDc": "Grunn léna hluturt", + "DisplayName:Abp.Ldap.Domain": "Lén", + "Description:Abp.Ldap.Domain": "Lén", "DisplayName:Abp.Ldap.UserName": "Notanda nafn", "Description:Abp.Ldap.UserName": "Notanda nafn", "DisplayName:Abp.Ldap.Password": "Lykilorð", "Description:Abp.Ldap.Password": "Lykilorð" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/it.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/it.json index c9055d35ef..0f5b2776df 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/it.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/it.json @@ -7,9 +7,11 @@ "Description:Abp.Ldap.ServerPort": "Porta del server", "DisplayName:Abp.Ldap.BaseDc": "Componente del dominio di base", "Description:Abp.Ldap.BaseDc": "Componente del dominio di base", + "DisplayName:Abp.Ldap.Domain": "Dominio", + "Description:Abp.Ldap.Domain": "Dominio", "DisplayName:Abp.Ldap.UserName": "Nome utente", "Description:Abp.Ldap.UserName": "Nome utente", "DisplayName:Abp.Ldap.Password": "Password", "Description:Abp.Ldap.Password": "Password" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/nl.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/nl.json index ce321ab712..893a3ca77f 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/nl.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/nl.json @@ -7,9 +7,11 @@ "Description:Abp.Ldap.ServerPort": "Server poort", "DisplayName:Abp.Ldap.BaseDc": "Basisdomein component", "Description:Abp.Ldap.BaseDc": "Basisdomein component", + "DisplayName:Abp.Ldap.Domain": "Domain", + "Description:Abp.Ldap.Domain": "Domain", "DisplayName:Abp.Ldap.UserName": "Gebruikersnaam", "Description:Abp.Ldap.UserName": "Gebruikersnaam", "DisplayName:Abp.Ldap.Password": "Wachtwoord", "Description:Abp.Ldap.Password": "Wachtwoord" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/pl-PL.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/pl-PL.json index 38cb777019..4cb41b07e6 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/pl-PL.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/pl-PL.json @@ -7,9 +7,11 @@ "Description:Abp.Ldap.ServerPort": "Port serwera", "DisplayName:Abp.Ldap.BaseDc": "Podstawowy składnik domeny", "Description:Abp.Ldap.BaseDc": "Podstawowy składnik domeny", + "DisplayName:Abp.Ldap.Domain": "Domena", + "Description:Abp.Ldap.Domain": "Domena", "DisplayName:Abp.Ldap.UserName": "Nazwa użytkownika", "Description:Abp.Ldap.UserName": "Nazwa użytkownika", "DisplayName:Abp.Ldap.Password": "Hasło", "Description:Abp.Ldap.Password": "Hasło" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/pt-BR.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/pt-BR.json index d7eea13cba..8cb19b17d2 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/pt-BR.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/pt-BR.json @@ -7,9 +7,11 @@ "Description:Abp.Ldap.ServerPort": "Porta do servidor", "DisplayName:Abp.Ldap.BaseDc": "Componente de domínio base", "Description:Abp.Ldap.BaseDc": "Componente de domínio base", + "DisplayName:Abp.Ldap.Domain": "Domínio", + "Description:Abp.Ldap.Domain": "Domínio", "DisplayName:Abp.Ldap.UserName": "Nome do usuário", "Description:Abp.Ldap.UserName": "Nome do usuário", "DisplayName:Abp.Ldap.Password": "Senha", "Description:Abp.Ldap.Password": "Senha" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/ro-RO.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/ro-RO.json index 0444f908b3..8119a5b924 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/ro-RO.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/ro-RO.json @@ -3,17 +3,15 @@ "texts": { "DisplayName:Abp.Ldap.ServerHost": "Server host", "Description:Abp.Ldap.ServerHost": "Server host", - "DisplayName:Abp.Ldap.ServerPort": "Server port", "Description:Abp.Ldap.ServerPort": "Server port", - "DisplayName:Abp.Ldap.BaseDc": "Componenta domeniului de bază", "Description:Abp.Ldap.BaseDc": "Componenta domeniului de bază", - + "DisplayName:Abp.Ldap.Domain": "Domeniu", + "Description:Abp.Ldap.Domain": "Domeniu", "DisplayName:Abp.Ldap.UserName": "Nume de utilizator", "Description:Abp.Ldap.UserName": "Nume de utilizator", - "DisplayName:Abp.Ldap.Password": "Parola", "Description:Abp.Ldap.Password": "Parola" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/ru.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/ru.json index 999861f7f6..fe5feb438c 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/ru.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/ru.json @@ -7,9 +7,11 @@ "Description:Abp.Ldap.ServerPort": "Порт сервера", "DisplayName:Abp.Ldap.BaseDc": "Компонент базового домена", "Description:Abp.Ldap.BaseDc": "Компонент базового домена", + "DisplayName:Abp.Ldap.Domain": "Домен", + "Description:Abp.Ldap.Domain": "Домен", "DisplayName:Abp.Ldap.UserName": "Имя пользователя", "Description:Abp.Ldap.UserName": "Имя пользователя", "DisplayName:Abp.Ldap.Password": "Пароль", "Description:Abp.Ldap.Password": "Пароль" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/sk.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/sk.json index 9c9195c4eb..d0cc258df1 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/sk.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/sk.json @@ -7,9 +7,11 @@ "Description:Abp.Ldap.ServerPort": "Server post", "DisplayName:Abp.Ldap.BaseDc": "Základný komponent domény", "Description:Abp.Ldap.BaseDc": "Základný komponent domény", + "DisplayName:Abp.Ldap.Domain": "doména", + "Description:Abp.Ldap.Domain": "doména", "DisplayName:Abp.Ldap.UserName": "Používateľské meno", "Description:Abp.Ldap.UserName": "Používateľské meno", "DisplayName:Abp.Ldap.Password": "Heslo", "Description:Abp.Ldap.Password": "Heslo" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/sl.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/sl.json index 96e67d02ec..b57f7a7474 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/sl.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/sl.json @@ -7,9 +7,11 @@ "Description:Abp.Ldap.ServerPort": "Vrata strežnika", "DisplayName:Abp.Ldap.BaseDc": "Komponenta osnovne domene", "Description:Abp.Ldap.BaseDc": "Komponenta osnovne domene", + "DisplayName:Abp.Ldap.Domain": "domena", + "Description:Abp.Ldap.Domain": "domena", "DisplayName:Abp.Ldap.UserName": "Uporabniško ime", "Description:Abp.Ldap.UserName": "Uporabniško ime", "DisplayName:Abp.Ldap.Password": "Geslo", "Description:Abp.Ldap.Password": "Geslo" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/tr.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/tr.json index 7aab9cc2d7..551b6047ad 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/tr.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/tr.json @@ -3,16 +3,14 @@ "texts": { "DisplayName:Abp.Ldap.ServerHost": "Sunucu Ana Bilgisayarı", "Description:Abp.Ldap.ServerHost": "Sunucu Ana Bilgisayarı", - "DisplayName:Abp.Ldap.ServerPort": "Sunucu portu", "Description:Abp.Ldap.ServerPort": "Sunucu portu", - "DisplayName:Abp.Ldap.BaseDc": "Temel alan bileşeni", "Description:Abp.Ldap.BaseDc": "Temel alan bileşeni", - + "DisplayName:Abp.Ldap.Domain": "Alan adı", + "Description:Abp.Ldap.Domain": "Alan adı", "DisplayName:Abp.Ldap.UserName": "Kullanıcı adı", "Description:Abp.Ldap.UserName": "Kullanıcı adı", - "DisplayName:Abp.Ldap.Password": "Parola", "Description:Abp.Ldap.Password": "Parola" } diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/vi.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/vi.json index f314ac7a5e..b2b103c248 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/vi.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/vi.json @@ -7,9 +7,11 @@ "Description:Abp.Ldap.ServerPort": "Cổng máy chủ", "DisplayName:Abp.Ldap.BaseDc": "Thành phần miền cơ sở", "Description:Abp.Ldap.BaseDc": "Thành phần miền cơ sở", + "DisplayName:Abp.Ldap.Domain": "Lãnh địa", + "Description:Abp.Ldap.Domain": "Lãnh địa", "DisplayName:Abp.Ldap.UserName": "tên tài khoản", "Description:Abp.Ldap.UserName": "tên tài khoản", "DisplayName:Abp.Ldap.Password": "Mật khẩu", "Description:Abp.Ldap.Password": "Mật khẩu" } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/zh-Hans.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/zh-Hans.json index 7efddf2682..dfc4fa6cea 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/zh-Hans.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/zh-Hans.json @@ -3,16 +3,14 @@ "texts": { "DisplayName:Abp.Ldap.ServerHost": "服务器主机", "Description:Abp.Ldap.ServerHost": "服务器主机", - "DisplayName:Abp.Ldap.ServerPort": "服务器端口", "Description:Abp.Ldap.ServerPort": "服务器端口", - "DisplayName:Abp.Ldap.BaseDc": "基域组件", "Description:Abp.Ldap.BaseDc": "基域组件", - + "DisplayName:Abp.Ldap.Domain": "域", + "Description:Abp.Ldap.Domain": "域", "DisplayName:Abp.Ldap.UserName": "用户名", "Description:Abp.Ldap.UserName": "用户名", - "DisplayName:Abp.Ldap.Password": "密码", "Description:Abp.Ldap.Password": "密码" } diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/zh-Hant.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/zh-Hant.json index d8338f1d29..c499e7a60b 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/zh-Hant.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/zh-Hant.json @@ -3,16 +3,14 @@ "texts": { "DisplayName:Abp.Ldap.ServerHost": "服務器主機", "Description:Abp.Ldap.ServerHost": "服務器主機", - "DisplayName:Abp.Ldap.ServerPort": "服務器端口", "Description:Abp.Ldap.ServerPort": "服務器端口", - "DisplayName:Abp.Ldap.BaseDc": "基域組件", "Description:Abp.Ldap.BaseDc": "基域組件", - + "DisplayName:Abp.Ldap.Domain": "域", + "Description:Abp.Ldap.Domain": "域", "DisplayName:Abp.Ldap.UserName": "用戶名", "Description:Abp.Ldap.UserName": "用戶名", - "DisplayName:Abp.Ldap.Password": "密碼", "Description:Abp.Ldap.Password": "密碼" } diff --git a/framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/AbpLdapTestModule.cs b/framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/AbpLdapTestModule.cs index 7982a483ac..4821b06651 100644 --- a/framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/AbpLdapTestModule.cs +++ b/framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/AbpLdapTestModule.cs @@ -1,5 +1,6 @@ using Volo.Abp.Autofac; using Volo.Abp.Modularity; +using Volo.Abp.Settings; namespace Volo.Abp.Ldap; @@ -12,13 +13,9 @@ public class AbpLdapTestModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { - Configure(options => + Configure(options => { - options.ServerHost = "192.168.0.3"; - options.ServerPort = 389; - options.BaseDc = "dc=abp,dc=io"; - options.UserName = "admin"; - options.Password = "123qwe"; + options.ValueProviders.Add(); }); } } diff --git a/framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/LdapManager_Tests.cs b/framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/LdapManager_Tests.cs index 5ae9447494..b1e8cf0535 100644 --- a/framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/LdapManager_Tests.cs +++ b/framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/LdapManager_Tests.cs @@ -1,10 +1,13 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; using Shouldly; using Volo.Abp.Testing; using Xunit; namespace Volo.Abp.Ldap; - +/// +/// docker run --name ldap -d --env LDAP_ORGANISATION="abp" --env LDAP_DOMAIN="abp.io" --env LDAP_ADMIN_PASSWORD="123qwe" -p 389:389 -p 636:639 osixia/openldap +/// public class LdapManager_Tests : AbpIntegratedTest { private readonly ILdapManager _ldapManager; @@ -19,10 +22,10 @@ public class LdapManager_Tests : AbpIntegratedTest options.UseAutofac(); } - [Fact(Skip = "Required Ldap environment")] + [Fact] public async Task AuthenticateAsync() { - (await _ldapManager.AuthenticateAsync("cn=abp,dc=abp,dc=io", "123qwe")).ShouldBe(true); + (await _ldapManager.AuthenticateAsync("cn=admin,dc=abp,dc=io", "123qwe")).ShouldBe(true); (await _ldapManager.AuthenticateAsync("cn=abp,dc=abp,dc=io", "123123")).ShouldBe(false); (await _ldapManager.AuthenticateAsync("NoExists", "123qwe")).ShouldBe(false); } diff --git a/framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/LdapOptions_Tests.cs b/framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/LdapOptions_Tests.cs deleted file mode 100644 index 569cc2b79b..0000000000 --- a/framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/LdapOptions_Tests.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Microsoft.Extensions.Options; -using Shouldly; -using Volo.Abp.Testing; -using Xunit; - -namespace Volo.Abp.Ldap; - -public class LdapOptions_Tests : AbpIntegratedTest -{ - protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) - { - options.UseAutofac(); - } - - [Fact] - public void Should_Resolve_AbpAbpLdapOptionsFactory() - { - GetRequiredService>().ShouldBeOfType(typeof(AbpAbpLdapOptionsManager)); - } -} diff --git a/framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/TestLdapSettingValueProvider.cs b/framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/TestLdapSettingValueProvider.cs new file mode 100644 index 0000000000..ca1d666a45 --- /dev/null +++ b/framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/TestLdapSettingValueProvider.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Settings; + +namespace Volo.Abp.Ldap; + +public class TestLdapSettingValueProvider : ISettingValueProvider, ITransientDependency +{ + public const string ProviderName = "Test"; + + public string Name => ProviderName; + + public Task GetOrNullAsync(SettingDefinition setting) + { + switch (setting.Name) + { + case LdapSettingNames.ServerHost: + return Task.FromResult("localhost"); + + case LdapSettingNames.ServerPort: + return Task.FromResult("389"); + + case LdapSettingNames.BaseDc: + return Task.FromResult("dc=abp,dc=io"); + + case LdapSettingNames.Domain: + return Task.FromResult(null); + + case LdapSettingNames.UserName: + return Task.FromResult("admin"); + + case LdapSettingNames.Password: + return Task.FromResult("123qwe"); + + default: + return Task.FromResult(null); + } + } + + public Task> GetAllAsync(SettingDefinition[] settings) + { + throw new NotImplementedException(); + } +}