Linger.Ldap.Contracts
1.4.0
See the version list below for details.
dotnet add package Linger.Ldap.Contracts --version 1.4.0
NuGet\Install-Package Linger.Ldap.Contracts -Version 1.4.0
<PackageReference Include="Linger.Ldap.Contracts" Version="1.4.0" />
<PackageVersion Include="Linger.Ldap.Contracts" Version="1.4.0" />
<PackageReference Include="Linger.Ldap.Contracts" />
paket add Linger.Ldap.Contracts --version 1.4.0
#r "nuget: Linger.Ldap.Contracts, 1.4.0"
#:package Linger.Ldap.Contracts@1.4.0
#addin nuget:?package=Linger.Ldap.Contracts&version=1.4.0
#tool nuget:?package=Linger.Ldap.Contracts&version=1.4.0
Linger.Ldap.Contracts
Core contracts and shared models for LDAP operations in .NET applications.
Introduction
Linger.Ldap.Contracts defines provider-agnostic abstractions so application code can work with a single LDAP API while switching between concrete implementations.
Supported Frameworks
- .NET 10.0
- .NET 9.0
- .NET 8.0
- .NET Standard 2.0
What This Package Contains
ILdapinterface for core LDAP operationsLdapConfigandLdapCredentialsconfiguration modelsAdUserInfounified user profile model
ASP.NET Core Integration
Configure Services
Register your LDAP configuration and one concrete provider implementation.
using Linger.Ldap.Contracts;
public void ConfigureServices(IServiceCollection services)
{
services.Configure<LdapConfig>(Configuration.GetSection("LdapConfig"));
// Choose exactly one provider implementation
services.AddScoped<ILdap, Linger.Ldap.ActiveDirectory.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"
]
}
}
Usage Examples
Validate User Credentials
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: cancellationToken);
if (isValid && userInfo is not null)
{
Console.WriteLine($"User {userInfo.DisplayName} authenticated successfully.");
return true;
}
return false;
}
}
Find and Search Users
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: cancellationToken);
}
public async Task<IEnumerable<AdUserInfo>> SearchUsersAsync(
string searchTerm,
CancellationToken cancellationToken = default)
{
return await _ldap.GetUsersAsync(
searchTerm,
cancellationToken: cancellationToken);
}
public async Task<bool> CheckUserExistsAsync(
string username,
CancellationToken cancellationToken = default)
{
return await _ldap.UserExistsAsync(
username,
cancellationToken: cancellationToken);
}
}
Search in a Specific OU with Custom Bind Credentials
var ldapCredentials = new LdapCredentials
{
BindDn = "readonly.user",
BindCredentials = "ReadonlyPassword123!"
};
var users = await _ldap.GetUsersAsync(
"alice",
ldapCredentials: ldapCredentials,
searchBase: "OU=Sales,DC=example,DC=com",
cancellationToken: cancellationToken);
Advanced Filter Search (Cross-Provider)
var advancedFilter = "(&(objectClass=person)(department=IT)(mail=*))";
var users = await _ldap.SearchUsersByFilterAsync(
advancedFilter,
searchBase: "DC=example,DC=com",
cancellationToken: cancellationToken);
Cancellation Support
All asynchronous LDAP operations support CancellationToken for timeout control and request cancellation.
public async Task<bool> ValidateUserWithTimeoutAsync(
ILdap ldap,
string username,
string password,
int timeoutSeconds = 5)
{
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(timeoutSeconds));
try
{
var (isValid, _) = await ldap.ValidateUserAsync(
username,
password,
cancellationToken: cts.Token);
return isValid;
}
catch (OperationCanceledException)
{
Console.WriteLine("LDAP validation timed out.");
return false;
}
}
Core Interface
public interface ILdap
{
Task<(bool IsValid, AdUserInfo? AdUserInfo)> ValidateUserAsync(
string userName,
string password,
string? searchBase = null,
CancellationToken cancellationToken = default);
Task<AdUserInfo?> FindUserAsync(
string userName,
LdapCredentials? ldapCredentials = null,
string? searchBase = null,
CancellationToken cancellationToken = default);
Task<IEnumerable<AdUserInfo>> GetUsersAsync(
string userName,
LdapCredentials? ldapCredentials = null,
string? searchBase = null,
CancellationToken cancellationToken = default);
Task<IEnumerable<AdUserInfo>> SearchUsersByFilterAsync(
string filter,
LdapCredentials? ldapCredentials = null,
string? searchBase = null,
CancellationToken cancellationToken = default);
Task<bool> UserExistsAsync(
string userName,
string? searchBase = null,
CancellationToken cancellationToken = default);
}
Core Models
LdapConfig
public class LdapConfig
{
public string Url { get; set; } = null!;
public bool Security { get; set; }
public string Domain { get; set; } = null!;
public LdapCredentials? Credentials { get; set; }
public string SearchBase { get; set; } = null!;
public string SearchFilter { get; set; } = null!;
public string[]? Attributes { get; set; }
}
AdUserInfo (Commonly Used Fields)
DisplayNameSamAccountNameUpnDnEmailDepartmentTitleMemberOfStatus
Supported Implementations
- Linger.Ldap.ActiveDirectory: implementation optimized for Microsoft Active Directory
- Linger.Ldap.Novell: cross-platform implementation based on Novell.Directory.Ldap
| 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.4.1-preview | 147 | 5/12/2026 |
| 1.4.0 | 149 | 5/6/2026 |
| 1.3.3-preview | 143 | 5/5/2026 |
| 1.3.2-preview | 152 | 4/29/2026 |
| 1.3.1-preview | 142 | 4/28/2026 |
| 1.3.0-preview | 142 | 4/27/2026 |
| 1.2.0-preview | 159 | 3/29/2026 |
| 1.1.0 | 173 | 2/4/2026 |
| 1.0.3-preview | 166 | 1/9/2026 |
| 1.0.2-preview | 167 | 1/8/2026 |
| 1.0.0 | 372 | 11/12/2025 |
| 1.0.0-preview2 | 221 | 11/6/2025 |
| 1.0.0-preview1 | 213 | 11/5/2025 |
| 0.9.9 | 206 | 10/16/2025 |
| 0.9.8 | 201 | 10/14/2025 |
| 0.9.7-preview | 197 | 10/13/2025 |
| 0.9.6-preview | 173 | 10/12/2025 |
| 0.9.5 | 207 | 9/28/2025 |
| 0.9.4-preview | 223 | 9/25/2025 |
| 0.9.3-preview | 240 | 9/22/2025 |