Browse Source
Merge pull request #5022 from abpframework/maliming/ldap-basedc
Add BaseDc to AbpLdapOptions.
pull/5024/head
maliming
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with
46 additions and
24 deletions
-
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpAbpLdapOptionsFactory.cs
-
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpLdapOptions.cs
-
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/ILdapManager.cs
-
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapManager.cs
-
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingNames.cs
-
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingProvider.cs
-
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/en.json
-
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/tr.json
-
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/zh-Hans.json
-
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/zh-Hant.json
-
framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/AbpLdapTestModule.cs
-
framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/LdapManager_Tests.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); |
|
|
|
} |
|
|
|
|
|
|
|
@ -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; } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -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); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -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) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
@ -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"; |
|
|
|
|
|
|
|
@ -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, |
|
|
|
"", |
|
|
|
|
|
|
|
@ -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", |
|
|
|
|
|
|
|
|
|
|
|
@ -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" |
|
|
|
} |
|
|
|
|
|
|
|
@ -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,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": "密碼" |
|
|
|
} |
|
|
|
|
|
|
|
@ -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"; |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@ -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); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|