Visus.BasicLdapAuthentication 1.0.0

dotnet add package Visus.BasicLdapAuthentication --version 1.0.0
                    
NuGet\Install-Package Visus.BasicLdapAuthentication -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Visus.BasicLdapAuthentication" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Visus.BasicLdapAuthentication" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Visus.BasicLdapAuthentication" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Visus.BasicLdapAuthentication --version 1.0.0
                    
#r "nuget: Visus.BasicLdapAuthentication, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Visus.BasicLdapAuthentication@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Visus.BasicLdapAuthentication&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Visus.BasicLdapAuthentication&version=1.0.0
                    
Install as a Cake Tool

Visus.BasicLdapAuthentication

Visus.BasicLdapAuthentication implements the basic (header-based) authentication scheme for ASP.NET Core application using Visus.DirectoryAuthentication or Visus.LdapAuthentication as backends.

Usage

  1. Add the services
  2. Interface with cookie authentication

Add the services

The authentication functionalityBasic is added in ConfigureServices in your Startup class or using the WebApplication builder in the minimal hosting model:

Or using the new "minimal hosting model":

using Visus.BasicLdapAuthentication;
using Visus.LdapAuthentication; // or Visus.DirectoryAuthentication;
// ...

var builder = WebApplication.CreateBuilder(args);
// ...

// Add basic authentication using LDAP.
builder.Services.AddAuthentication(BasicAuthenticationDefaults.AuthenticationScheme)
    .AddBasicLdapAuthentication(o => {
        builder.Configuration.GetSection(BasicAuthenticationOptions.Section).Bind(o);
        // The following statement filters out group-based claims as an example.
        o.ClaimFilter = (c, _) => (c != ClaimTypes.GroupSid) && (c != ClaimTypes.Role);
    });
});

// Add Visus.LdapAuthentication or Visus.DirectoryAuthentication as the
// authentication backend. No further configuration is required as the basic
// authentication handler will pull the configuration from the DI container.
builder.Services.AddLdapAuthentication(o => {
    builder.Configuration.GetSection(LdapOptions.Section).Bind(o);
});

// ...

app.UseAuthentication();
app.UseAuthorization();

/...

As pulling the login data from the LDAP server for each request can be expensive, the handler has the ability to interface the cookie authentication middleware:

builder.Services.AddAuthentication(BasicAuthenticationDefaults.AuthenticationScheme)
    .AddCookie(o => {
        // The login cookie is essential in the sense of GDPR.
        o.Cookie.IsEssential = true;
    }).AddBasicLdapAuthentication(o => {
        builder.Configuration.GetSection(BasicAuthenticationOptions.Section).Bind(o);

        // Tell the basic authentication handler to sign in using the default
        // cookie scheme.
        o.CookieScheme = CookieAuthenticationDefaults.AuthenticationScheme;
        // Allow the cookie to be refreshed.
        o.AllowCookieRefresh = true;
        // Set the lifetime of the cookie.
        o.CookieLifetime = TimeSpan.FromMinutes(30);
        // Allow the cookie to outlive the browser session.
        o.PersistentCookie = true;
    });
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 50 8/15/2026