diff --git a/framework/src/Volo.Abp.Ldap/Volo.Abp.Ldap.csproj b/framework/src/Volo.Abp.Ldap/Volo.Abp.Ldap.csproj
index 5339a68da1..850bd29303 100644
--- a/framework/src/Volo.Abp.Ldap/Volo.Abp.Ldap.csproj
+++ b/framework/src/Volo.Abp.Ldap/Volo.Abp.Ldap.csproj
@@ -17,9 +17,17 @@
-
+
+
+
+
+
+
+
+
+
diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpAbpLdapOptionsFactory.cs b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpAbpLdapOptionsFactory.cs
new file mode 100644
index 0000000000..8e744d414e
--- /dev/null
+++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpAbpLdapOptionsFactory.cs
@@ -0,0 +1,44 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Microsoft.Extensions.Options;
+using Volo.Abp.Options;
+using Volo.Abp.Settings;
+using Volo.Abp.Threading;
+
+namespace Volo.Abp.Ldap
+{
+ public class AbpAbpLdapOptionsFactory : AbpOptionsFactory
+ {
+ protected ISettingProvider SettingProvider { get; }
+
+ public AbpAbpLdapOptionsFactory(
+ IEnumerable> setups,
+ IEnumerable> postConfigures,
+ ISettingProvider settingProvider)
+ : base(setups, postConfigures)
+ {
+ SettingProvider = settingProvider;
+ }
+
+ public override AbpLdapOptions Create(string name)
+ {
+ var options = base.Create(name);
+
+ AsyncHelper.RunSync(() => OverrideOptionsAsync(options));
+
+ return options;
+ }
+
+ protected virtual async Task OverrideOptionsAsync(AbpLdapOptions options)
+ {
+ options.ServerHost = await SettingProvider.GetOrNullAsync(LdapSettingNames.ServerHost) ?? options.ServerHost;
+ options.ServerPort = await SettingProvider.GetAsync(LdapSettingNames.ServerPort, options.ServerPort);
+ options.UseSsl = await SettingProvider.GetAsync(LdapSettingNames.UseSsl, options.UseSsl);
+ options.SearchBase = await SettingProvider.GetOrNullAsync(LdapSettingNames.SearchBase) ?? options.SearchBase;
+ options.DomainName = await SettingProvider.GetOrNullAsync(LdapSettingNames.DomainName) ?? options.DomainName;
+ options.DomainDistinguishedName = await SettingProvider.GetOrNullAsync(LdapSettingNames.DomainDistinguishedName) ?? options.DomainDistinguishedName;
+ options.Credentials.DomainUserName = await SettingProvider.GetOrNullAsync(LdapSettingNames.Credentials.DomainUserName) ?? options.Credentials.DomainUserName;
+ options.Credentials.Password = await SettingProvider.GetOrNullAsync(LdapSettingNames.Credentials.Password) ?? options.Credentials.Password;
+ }
+ }
+}
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 216eee81b4..3978a1b1c1 100644
--- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpLdapModule.cs
+++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpLdapModule.cs
@@ -1,14 +1,43 @@
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.DependencyInjection.Extensions;
+using Microsoft.Extensions.Options;
+using Volo.Abp.Ldap.Localization;
+using Volo.Abp.Localization;
using Volo.Abp.Modularity;
+using Volo.Abp.Settings;
+using Volo.Abp.VirtualFileSystem;
namespace Volo.Abp.Ldap
{
+ [DependsOn(
+ typeof(AbpSettingsModule),
+ typeof(AbpVirtualFileSystemModule),
+ typeof(AbpLocalizationModule))]
public class AbpLdapModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
+ context.Services.Replace(ServiceDescriptor.Transient, AbpAbpLdapOptionsFactory>());
+ context.Services.Replace(ServiceDescriptor.Scoped, OptionsManager>());
+
var configuration = context.Services.GetConfiguration();
- Configure(configuration.GetSection("LDAP"));
+ var ldapConfiguration = configuration["LDAP"];
+ if (!ldapConfiguration.IsNullOrEmpty())
+ {
+ Configure(configuration.GetSection("LDAP"));
+ }
+
+ Configure(options =>
+ {
+ options.FileSets.AddEmbedded();
+ });
+
+ Configure(options =>
+ {
+ options.Resources
+ .Add("en")
+ .AddVirtualJson("/Volo/Abp/Ldap/Localization");
+ });
}
}
}
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 77d8d04d91..acd7996c32 100644
--- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapManager.cs
+++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapManager.cs
@@ -251,8 +251,8 @@ namespace Volo.Abp.Ldap
protected virtual ILdapConnection GetConnection(string bindUserName = null, string bindUserPassword = null)
{
// bindUserName/bindUserPassword only be used when authenticate
- bindUserName = bindUserName ?? LdapOptions.Credentials.DomainUserName;
- bindUserPassword = bindUserPassword ?? LdapOptions.Credentials.Password;
+ bindUserName ??= LdapOptions.Credentials.DomainUserName;
+ bindUserPassword ??= LdapOptions.Credentials.Password;
var ldapConnection = new LdapConnection() { SecureSocketLayer = LdapOptions.UseSsl };
if (LdapOptions.UseSsl)
diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingNames.cs b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingNames.cs
new file mode 100644
index 0000000000..cfd851c12f
--- /dev/null
+++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingNames.cs
@@ -0,0 +1,24 @@
+namespace Volo.Abp.Ldap
+{
+ public static class LdapSettingNames
+ {
+ public const string ServerHost = "Abp.Ldap.ServerHost";
+
+ public const string ServerPort = "Abp.Ldap.ServerPort";
+
+ public const string UseSsl = "Abp.Ldap.UseSsl";
+
+ public const string SearchBase = "Abp.Ldap.SearchBase";
+
+ public const string DomainName = "Abp.Ldap.DomainName";
+
+ public const string DomainDistinguishedName = "Abp.Ldap.DomainDistinguishedName";
+
+ public static class Credentials
+ {
+ public const string DomainUserName = "Abp.Ldap.Credentials.DomainUserName";
+
+ public const string Password = "Abp.Ldap.Credentials.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
new file mode 100644
index 0000000000..73dad5d73d
--- /dev/null
+++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingProvider.cs
@@ -0,0 +1,67 @@
+using Volo.Abp.Ldap.Localization;
+using Volo.Abp.Localization;
+using Volo.Abp.Settings;
+
+namespace Volo.Abp.Ldap
+{
+ public class LdapSettingProvider : 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,
+ "",
+ L("DisplayName:Abp.Ldap.ServerPort"),
+ L("Description:Abp.Ldap.ServerPort")),
+
+ new SettingDefinition(
+ LdapSettingNames.UseSsl,
+ "",
+ L("DisplayName:Abp.Ldap.UseSsl"),
+ L("Description:Abp.Ldap.UseSsl")),
+
+ new SettingDefinition(
+ LdapSettingNames.SearchBase,
+ "",
+ L("DisplayName:Abp.Ldap.SearchBase"),
+ L("Description:Abp.Ldap.SearchBase")),
+
+ new SettingDefinition(
+ LdapSettingNames.DomainName,
+ "",
+ L("DisplayName:Abp.Ldap.DomainName"),
+ L("Description:Abp.Ldap.DomainName")),
+
+ new SettingDefinition(
+ LdapSettingNames.DomainDistinguishedName,
+ "",
+ L("DisplayName:Abp.Ldap.DomainDistinguishedName"),
+ L("Description:Abp.Ldap.DomainDistinguishedName")),
+
+ new SettingDefinition(
+ LdapSettingNames.Credentials.DomainUserName,
+ "",
+ L("DisplayName:Abp.Ldap.Credentials.DomainUserName"),
+ L("Description:Abp.Ldap.Credentials.DomainUserName")),
+
+ new SettingDefinition(
+ LdapSettingNames.Credentials.Password,
+ "",
+ L("DisplayName:Abp.Ldap.Credentials.Password"),
+ L("Description:Abp.Ldap.Credentials.Password"))
+ );
+ }
+
+ private static LocalizableString L(string name)
+ {
+ return LocalizableString.Create(name);
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/LdapResource.cs b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/LdapResource.cs
new file mode 100644
index 0000000000..e45b6797b5
--- /dev/null
+++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/LdapResource.cs
@@ -0,0 +1,10 @@
+using Volo.Abp.Localization;
+
+namespace Volo.Abp.Ldap.Localization
+{
+ [LocalizationResourceName("AbpLdap")]
+ public class LdapResource
+ {
+
+ }
+}
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
new file mode 100644
index 0000000000..973e059684
--- /dev/null
+++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/en.json
@@ -0,0 +1,28 @@
+{
+ "culture": "en",
+ "texts": {
+ "DisplayName:Abp.Ldap.ServerHost": "ServerHost",
+ "Description:Abp.Ldap.ServerHost": "ServerHost",
+
+ "DisplayName:Abp.Ldap.ServerPort": "ServerPort",
+ "Description:Abp.Ldap.ServerPort": "ServerPort",
+
+ "DisplayName:Abp.Ldap.UseSsl": "UseSsl",
+ "Description:Abp.Ldap.UseSsl": "UseSsl",
+
+ "DisplayName:Abp.Ldap.SearchBase": "SearchBase",
+ "Description:Abp.Ldap.SearchBase": "SearchBase",
+
+ "DisplayName:Abp.Ldap.DomainName": "DomainName",
+ "Description:Abp.Ldap.DomainName": "DomainName",
+
+ "DisplayName:Abp.Ldap.DomainDistinguishedName": "DomainDistinguishedName",
+ "Description:Abp.Ldap.DomainDistinguishedName": "DomainDistinguishedName",
+
+ "DisplayName:Abp.Ldap.Credentials.DomainUserName": "Credentials DomainUserName",
+ "Description:Abp.Ldap.Credentials.DomainUserName": "Credentials DomainUserName",
+
+ "DisplayName:Abp.Ldap.Credentials.Password": "Credentials Password",
+ "Description:Abp.Ldap.Credentials.Password": "Credentials Password",
+ }
+}
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
new file mode 100644
index 0000000000..eac7a9dbec
--- /dev/null
+++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/tr.json
@@ -0,0 +1,28 @@
+{
+ "culture": "tr",
+ "texts": {
+ "DisplayName:Abp.Ldap.ServerHost": "ServerHost",
+ "Description:Abp.Ldap.ServerHost": "ServerHost",
+
+ "DisplayName:Abp.Ldap.ServerPort": "ServerPort",
+ "Description:Abp.Ldap.ServerPort": "ServerPort",
+
+ "DisplayName:Abp.Ldap.UseSsl": "UseSsl",
+ "Description:Abp.Ldap.UseSsl": "UseSsl",
+
+ "DisplayName:Abp.Ldap.SearchBase": "SearchBase",
+ "Description:Abp.Ldap.SearchBase": "SearchBase",
+
+ "DisplayName:Abp.Ldap.DomainName": "DomainName",
+ "Description:Abp.Ldap.DomainName": "DomainName",
+
+ "DisplayName:Abp.Ldap.DomainDistinguishedName": "DomainDistinguishedName",
+ "Description:Abp.Ldap.DomainDistinguishedName": "DomainDistinguishedName",
+
+ "DisplayName:Abp.Ldap.Credentials.DomainUserName": "Credentials DomainUserName",
+ "Description:Abp.Ldap.Credentials.DomainUserName": "Credentials DomainUserName",
+
+ "DisplayName:Abp.Ldap.Credentials.Password": "Credentials Password",
+ "Description:Abp.Ldap.Credentials.Password": "Credentials Password",
+ }
+}
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
new file mode 100644
index 0000000000..94c0df37c1
--- /dev/null
+++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/zh-Hans.json
@@ -0,0 +1,28 @@
+{
+ "culture": "zh-Hans",
+ "texts": {
+ "DisplayName:Abp.Ldap.ServerHost": "ServerHost",
+ "Description:Abp.Ldap.ServerHost": "ServerHost",
+
+ "DisplayName:Abp.Ldap.ServerPort": "ServerPort",
+ "Description:Abp.Ldap.ServerPort": "ServerPort",
+
+ "DisplayName:Abp.Ldap.UseSsl": "UseSsl",
+ "Description:Abp.Ldap.UseSsl": "UseSsl",
+
+ "DisplayName:Abp.Ldap.SearchBase": "SearchBase",
+ "Description:Abp.Ldap.SearchBase": "SearchBase",
+
+ "DisplayName:Abp.Ldap.DomainName": "DomainName",
+ "Description:Abp.Ldap.DomainName": "DomainName",
+
+ "DisplayName:Abp.Ldap.DomainDistinguishedName": "DomainDistinguishedName",
+ "Description:Abp.Ldap.DomainDistinguishedName": "DomainDistinguishedName",
+
+ "DisplayName:Abp.Ldap.Credentials.DomainUserName": "Credentials DomainUserName",
+ "Description:Abp.Ldap.Credentials.DomainUserName": "Credentials DomainUserName",
+
+ "DisplayName:Abp.Ldap.Credentials.Password": "Credentials Password",
+ "Description:Abp.Ldap.Credentials.Password": "Credentials 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
new file mode 100644
index 0000000000..9822a9b6dc
--- /dev/null
+++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/zh-Hant.json
@@ -0,0 +1,28 @@
+{
+ "culture": "zh-Hant",
+ "texts": {
+ "DisplayName:Abp.Ldap.ServerHost": "ServerHost",
+ "Description:Abp.Ldap.ServerHost": "ServerHost",
+
+ "DisplayName:Abp.Ldap.ServerPort": "ServerPort",
+ "Description:Abp.Ldap.ServerPort": "ServerPort",
+
+ "DisplayName:Abp.Ldap.UseSsl": "UseSsl",
+ "Description:Abp.Ldap.UseSsl": "UseSsl",
+
+ "DisplayName:Abp.Ldap.SearchBase": "SearchBase",
+ "Description:Abp.Ldap.SearchBase": "SearchBase",
+
+ "DisplayName:Abp.Ldap.DomainName": "DomainName",
+ "Description:Abp.Ldap.DomainName": "DomainName",
+
+ "DisplayName:Abp.Ldap.DomainDistinguishedName": "DomainDistinguishedName",
+ "Description:Abp.Ldap.DomainDistinguishedName": "DomainDistinguishedName",
+
+ "DisplayName:Abp.Ldap.Credentials.DomainUserName": "Credentials DomainUserName",
+ "Description:Abp.Ldap.Credentials.DomainUserName": "Credentials DomainUserName",
+
+ "DisplayName:Abp.Ldap.Credentials.Password": "Credentials Password",
+ "Description:Abp.Ldap.Credentials.Password": "Credentials Password",
+ }
+}