Search code examples
ldapasp.net-coreasp.net-identityopeniddict

Is it possible to use OpenIddict and LDAP together?


I would like to authenticate users against Active Directory using LDAP. Is it possible with OpenIddict ?

Currently, I have Front end (Angularjs) + Back end (Web.API with ASP.NET Core and OpenIddict) which works perfect. Part of users use individual user accounts and they will continue. Another part of users should use AD accounts. It is inside internal network and would like to use already existing Active Directory for that.

Please suggest any solutions for that.

Thanks.


Solution

  • Please suggest any solutions for that.

    OpenIddict is never responsible of the login/authentication part, so you can freely implement it to use LDAP with both interactive flows like the code flow and with non-interactive flows like the password flow.


    If your AD servers can run Active Directory Federation Services, I'd recommend using it, as it's the best way to achieve what you want.

    Depending on the version you're using, you'll be able to integrate with any ASP.NET Core app quite easily (the 2016 version supports OpenID Connect while the previous one supports OAuth2: both can be used with the OAuth2/OIDC middleware developed by the ASP.NET team).

    If you can't use ADFS, another option is to use Integrated Windows Authentication. It's currently only supported when hosting your application behind IIS or when using WebListener.

    If none of these options work for your scenario, you can opt for the "low-level LDAP validation" route. Though it's not officially supported by .NET Core, there are a few libraries developed by the community that you can use: https://github.com/dotnet/corefx/issues/2089#issuecomment-231994908.