VOOZH about

URL: https://www.nuget.org/packages/Eaf.Middleware.Ldap/

⇱ NuGet Gallery | Eaf.Middleware.Ldap 9.1.0




👁 Image
Eaf.Middleware.Ldap 9.1.0

Prefix Reserved
dotnet add package Eaf.Middleware.Ldap --version 9.1.0
 
 
NuGet\Install-Package Eaf.Middleware.Ldap -Version 9.1.0
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Eaf.Middleware.Ldap" Version="9.1.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Eaf.Middleware.Ldap" Version="9.1.0" />
 
Directory.Packages.props
<PackageReference Include="Eaf.Middleware.Ldap" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Eaf.Middleware.Ldap --version 9.1.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Eaf.Middleware.Ldap, 9.1.0"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Eaf.Middleware.Ldap@9.1.0
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Eaf.Middleware.Ldap&version=9.1.0
 
Install as a Cake Addin
#tool nuget:?package=Eaf.Middleware.Ldap&version=9.1.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Eaf.Middleware.Ldap

Descrição Técnica

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.

Relação com o EAF e ASP.NET Boilerplate

Integração com ABP

  • Abp: Framework base para injeção de dependência e configuração
  • Abp.Zero.Common: Funcionalidades comuns do ABP Zero

Dependências Externas

  • Novell.Directory.Ldap.NET: Cliente LDAP para .NET
  • System.DirectoryServices: Integração nativa com Active Directory

Principais Componentes

LdapAuthenticationSource

Implementação de autenticação externa via LDAP:

  • Conexão com servidor LDAP
  • Validação de credenciais
  • Sincronização de usuários
  • Mapeamento de atributos LDAP
LdapSettings

Configurações de conexão LDAP:

  • Endereço do servidor
  • Porta (padrão: 389 para LDAP, 636 para LDAPS)
  • Base DN
  • Atributos de usuário
  • Configurações de SSL/TLS

Guia de Instalação

Pré-requisitos

  • .NET 10.0 SDK ou superior
  • ASP.NET Boilerplate 10.4.0
  • Servidor LDAP ou Active Directory configurado

Instalação via NuGet

dotnet add package Eaf.Middleware.Ldap --version 10.4.0

Instalação via Referência de Projeto

Adicione a referência ao seu arquivo .csproj:

<ProjectReference Include="..\Eaf.Middleware.Ldap\Eaf.Middleware.Ldap.csproj" />

Exemplo Básico de Uso

1. Registrando o Módulo

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

2. Configurando LDAP

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

3. Configurando para Active Directory

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

4. Usando Autenticação LDAP

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;
 }
 }
}

5. Sincronizando Usuários do LDAP

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
 }
 );
 }
}

Estrutura do Módulo

Eaf.Middleware.Ldap/
├── Ldap/ # Implementações LDAP
│ ├── LdapAuthenticationSource.cs
│ ├── LdapSettings.cs
│ └── LdapUserManager.cs
└── MiddlewareLdapModule.cs # Módulo ABP

Configurações Opcionais

Configuração de Timeout

{
 "Ldap": {
 "Server": "ldap.example.com",
 "Port": 389,
 "ConnectionTimeout": 30,
 "SearchTimeout": 60
 }
}

Configuração de Atributos Personalizados

{
 "Ldap": {
 "CustomAttributes": {
 "Department": "department",
 "Title": "title",
 "Phone": "telephoneNumber"
 }
 }
}

Filtro de Usuários

public override void PreInitialize()
{
 Configuration.Modules.EafLdap().UserFilter = "(objectClass=user)";
 Configuration.Modules.EafLdap().Enabled = true;
}

Testes

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%)

Licença

Este projeto faz parte do Enterprise Application Foundation (EAF) e está licenciado sob os mesmos termos do projeto principal.

Suporte

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Eaf.Middleware.Ldap:

Package Downloads
Eaf.Middleware.Core

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.1.0 80 6/17/2026
Loading failed