![]() |
VOOZH | about |
dotnet add package Eaf.Middleware.Ldap --version 9.1.0
NuGet\Install-Package Eaf.Middleware.Ldap -Version 9.1.0
<PackageReference Include="Eaf.Middleware.Ldap" Version="9.1.0" />
<PackageVersion Include="Eaf.Middleware.Ldap" Version="9.1.0" />Directory.Packages.props
<PackageReference Include="Eaf.Middleware.Ldap" />Project file
paket add Eaf.Middleware.Ldap --version 9.1.0
#r "nuget: Eaf.Middleware.Ldap, 9.1.0"
#:package Eaf.Middleware.Ldap@9.1.0
#addin nuget:?package=Eaf.Middleware.Ldap&version=9.1.0Install as a Cake Addin
#tool nuget:?package=Eaf.Middleware.Ldap&version=9.1.0Install as a Cake Tool
O Eaf.Middleware.Ldap é um módulo de autenticação LDAP/Active Directory. Este módulo fornece integração completa com diretórios LDAP para autenticação externa, permitindo que usuários autentiquem usando suas credenciais existentes.
Este módulo suporta tanto Active Directory quanto outros servidores LDAP compatíveis, facilitando a integração com infraestruturas existentes.
Implementação de autenticação externa via LDAP:
Configurações de conexão LDAP:
dotnet add package Eaf.Middleware.Ldap --version 10.4.0
Adicione a referência ao seu arquivo .csproj:
<ProjectReference Include="..\Eaf.Middleware.Ldap\Eaf.Middleware.Ldap.csproj" />
No seu módulo principal, herde de MiddlewareLdapModule:
[DependsOn(
typeof(MiddlewareLdapModule),
typeof(AbpZeroCommonModule)
)]
public class MyAuthenticationModule : AbpModule
{
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
}
}
No appsettings.json:
{
"Ldap": {
"Server": "ldap.example.com",
"Port": 389,
"UseSsl": false,
"Domain": "example.com",
"BaseDn": "DC=example,DC=com",
"UserDn": "CN=Users,DC=example,DC=com",
"UsernameAttribute": "sAMAccountName",
"EmailAttribute": "mail",
"FirstNameAttribute": "givenName",
"LastNameAttribute": "sn"
}
}
{
"Ldap": {
"Server": "ad.example.com",
"Port": 636,
"UseSsl": true,
"Domain": "example.com",
"BaseDn": "DC=example,DC=com",
"UserDn": "CN=Users,DC=example,DC=com",
"UsernameAttribute": "sAMAccountName",
"EmailAttribute": "mail",
"FirstNameAttribute": "givenName",
"LastNameAttribute": "sn"
}
}
public class LdapAuthenticationAppService : ApplicationService
{
private readonly LdapAuthenticationSource _ldapAuthSource;
public LdapAuthenticationAppService(LdapAuthenticationSource ldapAuthSource)
{
_ldapAuthSource = ldapAuthSource;
}
public async Task<bool> AuthenticateAsync(string username, string password)
{
try
{
var result = await _ldapAuthSource.AuthenticateAsync(username, password);
return result != null;
}
catch (Exception ex)
{
Logger.Error(ex, "LDAP authentication failed");
return false;
}
}
}
public class LdapSyncService : ApplicationService
{
private readonly LdapAuthenticationSource _ldapAuthSource;
public LdapSyncService(LdapAuthenticationSource ldapAuthSource)
{
_ldapAuthSource = ldapAuthSource;
}
public async Task SyncUserAsync(string username)
{
var user = await _ldapAuthSource.CreateOrUpdateUserAsync(
new ExternalAuthUserInfo
{
ProviderName = "LDAP",
ProviderKey = username,
Name = username
}
);
}
}
Eaf.Middleware.Ldap/
├── Ldap/ # Implementações LDAP
│ ├── LdapAuthenticationSource.cs
│ ├── LdapSettings.cs
│ └── LdapUserManager.cs
└── MiddlewareLdapModule.cs # Módulo ABP
{
"Ldap": {
"Server": "ldap.example.com",
"Port": 389,
"ConnectionTimeout": 30,
"SearchTimeout": 60
}
}
{
"Ldap": {
"CustomAttributes": {
"Department": "department",
"Title": "title",
"Phone": "telephoneNumber"
}
}
}
public override void PreInitialize()
{
Configuration.Modules.EafLdap().UserFilter = "(objectClass=user)";
Configuration.Modules.EafLdap().Enabled = true;
}
Os testes para este módulo estão localizados em:
test/Eaf.Middleware.Ldap.Tests/
Para executar os testes:
dotnet test test/Eaf.Middleware.Ldap.Tests/Eaf.Middleware.Ldap.Tests.csproj
Cobertura Atual: 5.1% (necessita expansão para atingir meta de 90%)
Este projeto faz parte do Enterprise Application Foundation (EAF) e está licenciado sob os mesmos termos do projeto principal.
Para issues e perguntas, consulte o repositório principal do EAF: https://github.com/afonsoft/EAF
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on Eaf.Middleware.Ldap:
| Package | Downloads |
|---|---|
|
Eaf.Middleware.Core
Package Description |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 9.1.0 | 80 | 6/17/2026 |