Browse Source

Add BaseDc to AbpLdapOptions.

pull/5022/head
maliming 6 years ago
parent
commit
564d8ffcfd
  1. 1
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpAbpLdapOptionsFactory.cs
  2. 8
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpLdapOptions.cs
  3. 10
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/ILdapManager.cs
  4. 14
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapManager.cs
  5. 2
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingNames.cs
  6. 6
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingProvider.cs
  7. 3
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/en.json
  8. 6
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/tr.json
  9. 6
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/zh-Hans.json
  10. 6
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/zh-Hant.json
  11. 3
      framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/AbpLdapTestModule.cs
  12. 5
      framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/LdapManager_Tests.cs

1
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpAbpLdapOptionsFactory.cs

@ -34,6 +34,7 @@ namespace Volo.Abp.Ldap
{
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);
}

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

@ -6,8 +6,16 @@
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; }
}
}

10
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/ILdapManager.cs

@ -2,16 +2,6 @@
{
public interface ILdapManager
{
/// <summary>
/// Authenticate with default username/password
/// </summary>
/// <returns></returns>
bool Authenticate();
/// <summary>
/// Authenticate with specified username/password
/// </summary>
/// <returns></returns>
bool Authenticate(string username, string password);
}
}

14
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapManager.cs

@ -19,18 +19,15 @@ namespace Volo.Abp.Ldap
Logger = NullLogger<LdapManager>.Instance;
}
public virtual bool Authenticate()
{
return Authenticate(LdapOptions.UserName, LdapOptions.Password);
}
public bool Authenticate(string username, string password)
{
try
{
var conn = CreateLdapConnection();
AuthenticateLdapConnection(conn, username, password);
return true;
using (var conn = CreateLdapConnection())
{
AuthenticateLdapConnection(conn, username, password);
return true;
}
}
catch (Exception ex)
{
@ -47,7 +44,6 @@ namespace Volo.Abp.Ldap
return ldapConnection;
}
protected virtual void ConfigureLdapConnection(ILdapConnection connection)
{

2
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingNames.cs

@ -6,6 +6,8 @@
public const string ServerPort = "Abp.Ldap.ServerPort";
public const string BaseDc = "Abp.Ldap.BaseDc";
public const string UserName = "Abp.Ldap.UserName";
public const string Password = "Abp.Ldap.Password";

6
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingProvider.cs

@ -21,6 +21,12 @@ namespace Volo.Abp.Ldap
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,
"",

3
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/en.json

@ -7,6 +7,9 @@
"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.UserName": "Username",
"Description:Abp.Ldap.UserName": "Username",

6
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/tr.json

@ -3,10 +3,16 @@
"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.UserName": "Kullanıcı adı",
"Description:Abp.Ldap.UserName": "Kullanıcı adı",
"DisplayName:Abp.Ldap.Password": "parola",
"Description:Abp.Ldap.Password": "parola"
}

6
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/zh-Hans.json

@ -3,10 +3,16 @@
"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.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,10 +3,16 @@
"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.UserName": "用戶名",
"Description:Abp.Ldap.UserName": "用戶名",
"DisplayName:Abp.Ldap.Password": "密碼",
"Description:Abp.Ldap.Password": "密碼"
}

3
framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/AbpLdapTestModule.cs

@ -16,7 +16,8 @@ namespace Volo.Abp.Ldap
{
options.ServerHost = "192.168.0.3";
options.ServerPort = 389;
options.UserName = "cn=admin,dc=abp,dc=io";
options.BaseDc = "dc=abp,dc=io";
options.UserName = "admin";
options.Password = "123qwe";
});
}

5
framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/LdapManager_Tests.cs

@ -1,5 +1,4 @@
using System;
using Shouldly;
using Shouldly;
using Volo.Abp.Testing;
using Xunit;
@ -22,10 +21,8 @@ namespace Volo.Abp.Ldap
[Fact(Skip = "Required Ldap environment")]
public void Authenticate()
{
_ldapManager.Authenticate().ShouldBe(true);
_ldapManager.Authenticate("cn=abp,dc=abp,dc=io", "123qwe").ShouldBe(true);
_ldapManager.Authenticate("NoExists", "123qwe").ShouldBe(false);
}
}
}

Loading…
Cancel
Save