Skip to content

DotNet Directory Services Library - A convenience wrapper over LDAP

License

Notifications You must be signed in to change notification settings

maiorsi/directory-services

Repository files navigation

Build & Release

Directory Services

DotNet Directory Services Library

This library provides a convenience wrapper of LDAP queries from C# including the following:

Getting Started

Installation

Use the DotNet CLI package manager dotnet to build the project.

dotnet restore
dotnet build

Usage

App Settings

{
    "Ldap": {
        "BindDistinguishedName": "DN here",
        "BindPassword": "Password here",
        "DefaultLdapUsersSearchBase": "DN search base here",
        "DefaultLdapGroupsSearchBase": "DN search base here",
        "DistinguishedNameEscapeCharactersString": "\\,:\\5C\\2C|\\*:\\5C\\2A|\\(:\\5C\\28|\\):\\5C\\29|\\\\:\\5C\\5C",
        "Domain": "local",
        "LdapConnectionFallback": "LDAP://ldap.local.domain",
        "LdapConnectionOverride": "",
        "LdapConnectionUrl": "ldap.local.domain",
        "LdapFollowReferrals": true,
        "LdapKerberosBind": false,
        "LdapSecure": false
    }
}

Dependency Injection

// Part 1 - Add to services container
services.AddSingleton<IDirectoyService, NovellDirectoryService>();

// OR
services.AddSingleton<IDirectoyService, ActiveDirectoryService>();

// Part 2 - Use
public class UsersController : ControllerBase
{
    private readonly IDirectoryService _directoryService;

    public UsersController(IDirectoryService directoryService)
    {
        _directorService = directoryService ?? throw new ArgumentNullException(nameof(directorService));
    }

    private TestMethod()
    {
        var userBySid = _directoryService.SearchUserBySid("S-1-5....");
        var userByGuid = _directoryService.SearchUserByGuid("12345-aedgf234...");
    }
}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

About

DotNet Directory Services Library - A convenience wrapper over LDAP

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages