Browse Source

Add domain setting to LDAP.

Resolve #10927
pull/11156/head
maliming 4 years ago
parent
commit
38fa800afe
No known key found for this signature in database GPG Key ID: 96224957E51C89E
  1. 33
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpAbpLdapOptionsManager.cs
  2. 5
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpLdapModule.cs
  3. 20
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpLdapOptions.cs
  4. 18
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/ILdapSettingProvider.cs
  5. 11
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapManager.cs
  6. 55
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingDefinitionProvider.cs
  7. 2
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingNames.cs
  8. 73
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingProvider.cs
  9. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/ar.json
  10. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/cs.json
  11. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/de-DE.json
  12. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/en-GB.json
  13. 6
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/en.json
  14. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/es.json
  15. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/fi.json
  16. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/fr.json
  17. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/hi.json
  18. 7
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/hu.json
  19. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/is.json
  20. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/it.json
  21. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/nl.json
  22. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/pl-PL.json
  23. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/pt-BR.json
  24. 8
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/ro-RO.json
  25. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/ru.json
  26. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/sk.json
  27. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/sl.json
  28. 6
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/tr.json
  29. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/vi.json
  30. 6
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/zh-Hans.json
  31. 6
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/zh-Hant.json
  32. 9
      framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/AbpLdapTestModule.cs
  33. 11
      framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/LdapManager_Tests.cs
  34. 20
      framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/LdapOptions_Tests.cs
  35. 46
      framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/TestLdapSettingValueProvider.cs

33
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpAbpLdapOptionsManager.cs

@ -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<AbpLdapOptions>
{
protected ISettingProvider SettingProvider { get; }
public AbpAbpLdapOptionsManager(IOptionsFactory<AbpLdapOptions> 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<string> GetSettingOrDefaultValue(string name, string defaultValue)
{
var value = await SettingProvider.GetOrNullAsync(name);
return value.IsNullOrWhiteSpace() ? defaultValue : value;
}
}

5
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<AbpLdapOptions, AbpAbpLdapOptionsManager>();
var configuration = context.Services.GetConfiguration();
Configure<AbpLdapOptions>(configuration.GetSection("Ldap"));
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<AbpLdapModule>();

20
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpLdapOptions.cs

@ -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; }
/// <summary>
/// BindDN
/// </summary>
public string UserName { get; set; }
/// <summary>
///BindPassword
/// </summary>
public string Password { get; set; }
}

18
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<string> GetServerHostAsync();
public Task<int> GetServerPortAsync();
public Task<string> GetBaseDcAsync();
public Task<string> GetDomainDcAsync();
public Task<string> GetUserNameAsync();
public Task<string> GetPasswordAsync();
}

11
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<LdapManager> Logger { get; set; }
protected IOptions<AbpLdapOptions> LdapOptions { get; }
protected ILdapSettingProvider LdapSettingProvider { get; }
public LdapManager(IOptions<AbpLdapOptions> ldapOptions)
public LdapManager(ILdapSettingProvider ldapSettingProvider)
{
LdapOptions = ldapOptions;
LdapSettingProvider = ldapSettingProvider;
Logger = NullLogger<LdapManager>.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)

55
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<LdapResource>(name);
}
}

2
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";

73
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<string> GetServerHostAsync()
{
return await SettingProvider.GetOrNullAsync(LdapSettingNames.ServerHost);
}
public async Task<int> GetServerPortAsync()
{
return (await SettingProvider.GetOrNullAsync(LdapSettingNames.ServerPort))?.To<int>() ?? default;
}
public async Task<string> GetBaseDcAsync()
{
return await SettingProvider.GetOrNullAsync(LdapSettingNames.BaseDc);
}
public async Task<string> GetDomainDcAsync()
{
return await SettingProvider.GetOrNullAsync(LdapSettingNames.Domain);
}
public async Task<string> 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<string> GetPasswordAsync()
{
return LocalizableString.Create<LdapResource>(name);
return await SettingProvider.GetOrNullAsync(LdapSettingNames.Password);
}
}

4
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": "كلمة السر"
}
}
}

4
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"
}
}
}

4
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"
}
}
}

4
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"
}
}
}

6
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"
}

4
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"
}
}
}

4
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"
}
}
}

4
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"
}
}
}

4
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": "कुंजिका"
}
}
}

7
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ó"
}
}

4
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ð"
}
}
}

4
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"
}
}
}

4
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"
}
}
}

4
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"
}
}
}

4
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"
}
}
}

8
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"
}
}
}

4
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": "Пароль"
}
}
}

4
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"
}
}
}

4
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"
}
}
}

6
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"
}

4
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"
}
}
}

6
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": "密码"
}

6
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": "密碼"
}

9
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<AbpLdapOptions>(options =>
Configure<AbpSettingOptions>(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<TestLdapSettingValueProvider>();
});
}
}

11
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;
/// <summary>
/// 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
/// </summary>
public class LdapManager_Tests : AbpIntegratedTest<AbpLdapTestModule>
{
private readonly ILdapManager _ldapManager;
@ -19,10 +22,10 @@ public class LdapManager_Tests : AbpIntegratedTest<AbpLdapTestModule>
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);
}

20
framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/LdapOptions_Tests.cs

@ -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<AbpLdapTestModule>
{
protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options)
{
options.UseAutofac();
}
[Fact]
public void Should_Resolve_AbpAbpLdapOptionsFactory()
{
GetRequiredService<IOptions<AbpLdapOptions>>().ShouldBeOfType(typeof(AbpAbpLdapOptionsManager));
}
}

46
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<string> 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<string>(null);
case LdapSettingNames.UserName:
return Task.FromResult("admin");
case LdapSettingNames.Password:
return Task.FromResult("123qwe");
default:
return Task.FromResult<string>(null);
}
}
public Task<List<SettingValue>> GetAllAsync(SettingDefinition[] settings)
{
throw new NotImplementedException();
}
}
Loading…
Cancel
Save