Skip to content

Lightweight Directory Access Protocol

The GridLab LDAP framework consists of several modules that provide directory service integration for applications:

  • Microsoft Active Directory specific implementation
  • OpenLDAP servers

Both implementations provide the same core functionality but are optimized for their respective directory service technologies, ensuring optimal performance and compatibility with each platform's specific requirements and conventions.

The cross-platform LdapForNet library is used for Windows LDAP authentication. See LdapForNet GitHub repository for more information.

Installation

If you want to install ldap managers;

  • Add the GridLab.Abp.Ldap.ActiveDirectory or GridLab.Abp.Ldap.OpenLDAP NuGet package to your project:

    Install-Package GridLab.Abp.Ldap.ActiveDirectory

    Install-Package GridLab.Abp.Ldap.OpenLDAP

  • Choose AbpGridLabActiveDirectoryLdapModule Module When:

    • Working in Microsoft/Windows environments
    • Need integration with existing AD infrastructure
    • Require advanced features like Group Policy
    • Need Kerberos/NTLM authentication support
    // Active Directory - Flexible username formats
    protected virtual Task<string> NormalizeUserNameAsync(string userName)
    {
        // Supports UPN format (user@domain.com)
        if (userName.Contains("@") && !userName.Contains("/") && !userName.Contains("\\"))
        {
            return Task.FromResult(userName);
        }
        // Supports DN format (CN=user,OU=Users,DC=domain,DC=com)
        if (userName.Contains("=") && userName.Contains(","))
        {
            return Task.FromResult(userName);
        }
    }
    
    // Search filter using userPrincipalName
    protected virtual Task<string> GetUserFilterAsync(string userName)
    {
        return Task.FromResult($"(userPrincipalName={userName})");
    }
    
    • Add the AbpGridLabActiveDirectoryLdapModule to the dependency list of your module:

      [DependsOn(
          //...other dependencies
          typeof(AbpGridLabActiveDirectoryLdapModule) // <-- Add module dependency like that
      )]
      public class YourModule : AbpModule
      {
      }
      
  • Choose AbpGridLabOpenLdapModule Module When:

    • Working in Microsoft/Windows environments
    • Need integration with existing AD infrastructure
    • Require advanced features like Group Policy
    • Need Kerberos/NTLM authentication support
    // OpenLDAP - Structured DN format
    protected virtual async Task<string> NormalizeUserNameAsync(string userName)
    {
        // Creates full DN: cn=username,ou=users,dc=example,dc=com
        return $"cn={userName},{await LdapSettingProvider.GetSearchBaseAsync()}";
    }
    
    // Search filter using uid attribute
    protected virtual Task<string> GetUserFilterAsync(string userName)
    {
        return Task.FromResult($"(&(uid={userName}))");
    }
    
    • Add the AbpGridLabOpenLdapModule to the dependency list of your module:

      [DependsOn(
          //...other dependencies
          typeof(AbpGridLabOpenLdapModule) // <-- Add module dependency like that
      )]
      public class YourModule : AbpModule
      {
      }