Linger.Ldap.Contracts
1.0.2-preview
See the version list below for details.
dotnet add package Linger.Ldap.Contracts --version 1.0.2-preview
NuGet\Install-Package Linger.Ldap.Contracts -Version 1.0.2-preview
<PackageReference Include="Linger.Ldap.Contracts" Version="1.0.2-preview" />
<PackageVersion Include="Linger.Ldap.Contracts" Version="1.0.2-preview" />
<PackageReference Include="Linger.Ldap.Contracts" />
paket add Linger.Ldap.Contracts --version 1.0.2-preview
#r "nuget: Linger.Ldap.Contracts, 1.0.2-preview"
#:package Linger.Ldap.Contracts@1.0.2-preview
#addin nuget:?package=Linger.Ldap.Contracts&version=1.0.2-preview&prerelease
#tool nuget:?package=Linger.Ldap.Contracts&version=1.0.2-preview&prerelease
Linger.Ldap.Contracts
A C# LDAP contract library that provides standardized interfaces and models for integrating LDAP directory services across multiple .NET platforms.
Introduction
Linger.Ldap.Contracts provides a set of standardized LDAP operation interfaces and models, making it easier to implement consistent LDAP functionality across different .NET applications.
Features
Core Contracts
- Standardized LDAP operation interfaces
- Common LDAP attribute definitions
- Cross-platform compatible models
- Type-safe LDAP operations
Model Support
- Comprehensive user attribute mappings
- Groups and organizational unit models
- Search filter definitions
- Connection parameter contracts
ASP.NET Core Integration
Configuring Services
In ASP.NET Core projects, you can utilize LDAP services through dependency injection:
// Configure services in Program.cs or Startup.cs
public void ConfigureServices(IServiceCollection services)
{
// Add LDAP configuration
services.Configure<LdapConfig>(Configuration.GetSection("LdapConfig"));
// Register LDAP service depending on the implementation
// For Active Directory
services.AddScoped<ILdap, Linger.Ldap.ActiveDirectory.Ldap>();
// Or for Novell LDAP
// services.AddScoped<ILdap, Linger.Ldap.Novell.Ldap>();
}
appsettings.json example
{
"LdapConfig": {
"Url": "ldap.example.com",
"Domain": "example",
"SearchBase": "DC=example,DC=com",
"SearchFilter": "(&(objectClass=user)(|(sAMAccountName={0})(userPrincipalName={0})(mail={0})))",
"Security": true,
"Credentials": {
"BindDn": "serviceaccount",
"BindCredentials": "password"
},
"Attributes": [
"displayName", "mail", "sAMAccountName", "userPrincipalName",
"telephoneNumber", "department", "title", "givenName", "sn"
]
}
}
Usage examples
User authentication
public class AuthenticationService
{
private readonly ILdap _ldap;
public AuthenticationService(ILdap ldap)
{
_ldap = ldap;
}
public async Task<bool> AuthenticateUserAsync(
string username,
string password,
CancellationToken cancellationToken = default)
{
var (isValid, userInfo) = await _ldap.ValidateUserAsync(
username,
password,
cancellationToken);
if (isValid && userInfo != null)
{
// User authenticated successfully; you can use information from userInfo
Console.WriteLine($"User {userInfo.DisplayName} authenticated successfully");
return true;
}
return false;
}
}
Find user information
public class UserService
{
private readonly ILdap _ldap;
public UserService(ILdap ldap)
{
_ldap = ldap;
}
public async Task<AdUserInfo?> GetUserInfoAsync(
string username,
CancellationToken cancellationToken = default)
{
return await _ldap.FindUserAsync(username, cancellationToken);
}
public async Task<IEnumerable<AdUserInfo>> SearchUsersAsync(
string searchTerm,
CancellationToken cancellationToken = default)
{
return await _ldap.GetUsersAsync(searchTerm, cancellationToken);
}
public async Task<bool> CheckUserExistsAsync(
string username,
CancellationToken cancellationToken = default)
{
return await _ldap.UserExistsAsync(username, cancellationToken);
}
}
Cancellation support
All asynchronous LDAP operations support CancellationToken for timeout control and request cancellation:
public class LdapService
{
private readonly ILdap _ldap;
public LdapService(ILdap ldap)
{
_ldap = ldap;
}
// User validation with timeout
public async Task<bool> ValidateUserWithTimeoutAsync(
string username,
string password,
int timeoutSeconds = 5)
{
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(timeoutSeconds));
try
{
var (isValid, _) = await _ldap.ValidateUserAsync(
username,
password,
cts.Token);
return isValid;
}
catch (OperationCanceledException)
{
Console.WriteLine("LDAP validation timed out");
return false;
}
}
// Using request cancellation token in ASP.NET Core
public async Task<AdUserInfo?> GetUserForRequestAsync(
string username,
CancellationToken requestCancellationToken)
{
// If the client disconnects, the operation will be automatically canceled
return await _ldap.FindUserAsync(username, requestCancellationToken);
}
}
Supported implementations
The library provides the following LDAP directory service implementations:
- Linger.Ldap.ActiveDirectory - Implementation for Microsoft Active Directory
- Linger.Ldap.Novell - Cross-platform implementation using the Novell LDAP client library
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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 is compatible. 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 is compatible. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Linger.Ldap.Contracts:
| Package | Downloads |
|---|---|
|
Linger.Ldap.ActiveDirectory
Implementation of LDAP client functionality for Active Directory using System.DirectoryServices. Provides Windows-optimized AD connectivity with features for user authentication, information retrieval, group management, and specialized Active Directory operations. |
|
|
Linger.Ldap.Novell
Implementation of LDAP client functionality using the Novell.Directory.Ldap provider. Provides cross-platform LDAP connectivity with features such as authentication, user information retrieval, group management, and secure connections. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.6.0 | 41 | 7/25/2026 |
| 1.5.5 | 81 | 7/23/2026 |
| 1.5.4-preview | 127 | 7/21/2026 |
| 1.5.3-preview | 145 | 7/20/2026 |
| 1.5.2-preview | 145 | 7/19/2026 |
| 1.5.1-preview | 141 | 7/15/2026 |
| 1.5.0-preview | 142 | 7/14/2026 |
| 1.4.4-preview | 161 | 6/16/2026 |
| 1.4.3-preview | 154 | 6/15/2026 |
| 1.4.2 | 175 | 5/20/2026 |
| 1.4.1-preview | 164 | 5/12/2026 |
| 1.4.0 | 165 | 5/6/2026 |
| 1.3.3-preview | 158 | 5/5/2026 |
| 1.3.2-preview | 165 | 4/29/2026 |
| 1.3.1-preview | 155 | 4/28/2026 |
| 1.3.0-preview | 151 | 4/27/2026 |
| 1.2.0-preview | 170 | 3/29/2026 |
| 1.1.0 | 187 | 2/4/2026 |
| 1.0.3-preview | 177 | 1/9/2026 |
| 1.0.2-preview | 177 | 1/8/2026 |