Giter Club home page Giter Club logo

aspnetcore.ldapauthentication's Introduction

AspNetCore.LdapAuthentication

Fork of Justin.AspNetCore.LdapAuthentication.

Provides LDAP password authentication for an existing ASP.NET Core Identity user store via an LDAP bind. I created this for a project I'm working on with a very basic need, so it is not an exchaustive provider by any means.

License

MIT

Features

  • LDAP password authentication via a custom UserManager against any existing UserManager/UserStore combination.
  • Does not (yet) provide an LDAP based UserStore implementation
  • Does not support password changes or resets.

Possible Future Features

  • Full implementation of IUserStore and applicable interfaces around LDAP.

Dependencies

  • NETStandard 2.0.0
  • Novell.Directory.Ldap.NETStandard 2.3.8
  • Microsoft.AspNetCore.Identity 2.0.2

Getting Started

Setup ASP.NET Identity Core

Install the NuGet Package

Install-Package AspNetCore.LdapAuthentication

Create LdapAuth settings in appsettings.json:

  "LdapAuth": {
    "url": "ldap.local",
    "bindDn": "CN=user,OU=branch,DC=contoso,DC=local",
    "bindCredentials": "secret_password",
    "searchBase": "DC=contoso,DC=local",
    "searchFilter": "(&(objectClass=user)(objectClass=person)(sAMAccountName={0}))",
    "adminCn": "CN=Admins,OU=branch,DC=contoso,DC=local"
  },

Configure options and the custom User Manager in Startup before Identity:

// You can use services.AddLdapAuthentication(setupAction => {...}) to configure the 
// options manually instead of loading the configuration from Configuration.
services.Configure<AspNetCore.LdapAuthentication.LdapAuthenticationOptions>(this.Configuration.GetSection("LdapAuth"));

// Add the custom user manager.
services.AddIdentity<ApplicationUser, IdentityRole>()
    .AddUserManager<AspNetCore.LdapAuthentication.LdapUserManager<ApplicationUser>>()
    .AddEntityFrameworkStores<ApplicationDbContext>()
    .AddDefaultTokenProviders();

Use the normal sign-in method, and it will valid the user's passwod via an LDAP bind.

...
result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure: true);
...

Other Notes

By default, the result of the user store GetNormalizedUserNameAsync() method on the UserStore as the value for the distguished name when performing an LDAP bind. You can customize this by implementing a custom user store and the interface AspNetCore.LdapAuthentication.IUserLdapStore, which provides a GetDistinguishedNameAsync method that will be used instead of the normalized username.

aspnetcore.ldapauthentication's People

Contributors

jusbuc2k avatar ovation22 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.