CaseTunisia.Tools.Ldap 1.1.0

CaseTunisia.Tools.Ldap

This library is a wrapper around Novell.Directory.Ldap.NETStandard that authenticate and return the logged in user roles.

First add LdapConfiguration to you appsettings.json:

    "LdapConfiguration": {
        "Url": "172.168.1.3",
        "Port": 389,
        "SSL": true,
        "CertificatePath": "PATH_TO_CERT_FILE"
        "SearchBase": "OU=CASE Tunisia,DC=CASE-Tunisia,DC=internal",
        "SearchFilter": "(&(objectClass=user)(objectClass=person)(sAMAccountName={0}))",
    }
  • Initialize LdapConfiguration which is used to preconfigure LdapService
    services.Configure<LdapConfiguration>(Configuration.GetSection("LdapConfiguration"));
  • Add LdapService to your midlewares:
    services.AddSingleton<ILdapService, LdapService>();
  • Inject the service where you want to use it

demo code

LdapConfiguration ldapConfiguration = new()
{
    Url = "172.168.1.3",
    Port = 389,
    SearchBase = "OU=CASE Tunisia,DC=CASE-Tunisia,DC=internal",
    SearchFilter = "(&(objectClass=user)(objectClass=person)(sAMAccountName={0}))",
    UserName = $"case-tunisia\\git.user",
    Password = "case123",
};

...

LdapService _ldapService = new LdapService(ldapConfiguration);
_ldapService.Authenticate();
var user = _ldapService.GetUser($"case-tunisia\\a.habbachi");
List<string> roles = _ldapService.GetUserRoles(user);

No packages depend on CaseTunisia.Tools.Ldap.

Version Downloads Last updated
1.2.2 185 08/16/2024
1.2.1 97 05/31/2024
1.2.0 79 05/19/2024
1.1.0 75 05/06/2024
1.0.2 103 02/27/2024
1.0.1 91 02/06/2024
1.0.0 73 02/06/2024