Linger.Ldap.ActiveDirectory
1.4.0
.NET 8.0
This package targets .NET 8.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
dotnet add package Linger.Ldap.ActiveDirectory --version 1.4.0
NuGet\Install-Package Linger.Ldap.ActiveDirectory -Version 1.4.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="Linger.Ldap.ActiveDirectory" Version="1.4.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Linger.Ldap.ActiveDirectory" Version="1.4.0" />
<PackageReference Include="Linger.Ldap.ActiveDirectory" />
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 Linger.Ldap.ActiveDirectory --version 1.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Linger.Ldap.ActiveDirectory, 1.4.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 Linger.Ldap.ActiveDirectory@1.4.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=Linger.Ldap.ActiveDirectory&version=1.4.0
#tool nuget:?package=Linger.Ldap.ActiveDirectory&version=1.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Linger.Ldap.ActiveDirectory
An Active Directory focused LDAP client implementation based on System.DirectoryServices.
Features
- Active Directory user authentication and validation
- Async user lookup and search APIs
- OU-scoped search support via
searchBase - Optional
Attributesprojection to limit returned fields - LDAPS support via
LdapConfig.Security - Configurable
SearchFilterforFindUserAsyncandGetUsersAsync - Cross-provider advanced query via
ILdap.SearchUsersByFilterAsync - Optional domain controller auto-discovery when
LdapConfig.Urlis empty - Convenience constructor overloads (
new Ldap()/new Ldap(logger)) for auto-filling defaults (especiallySearchBase)
Supported Frameworks
- .NET 10.0
- .NET 9.0
- .NET 8.0
- .NET Standard 2.0
Installation
dotnet add package Linger.Ldap.ActiveDirectory
Quick Start
using Linger.Ldap.ActiveDirectory;
using Linger.Ldap.Contracts;
var config = new LdapConfig
{
Url = "example.com",
Domain = "example",
SearchBase = "DC=example,DC=com",
SearchFilter = "(&(objectClass=user)(sAMAccountName={0}))",
Security = true,
Credentials = new LdapCredentials
{
BindDn = "serviceAccount",
BindCredentials = "SecurePassword123!"
},
Attributes =
[
"displayName",
"sAMAccountName",
"mail",
"department",
"memberOf"
]
};
var ldap = new Ldap(config);
Convenience Creation with Auto Defaults
var ldap = new Ldap();
// With custom logger
var ldapWithLogger = new Ldap(logger);
When SearchBase is empty, the convenience constructor overloads infer it from Domain (for example, example.com → DC=example,DC=com) and then fall back to the current domain distinguished name.
Usage
Validate User Credentials
var (isValid, userInfo) = await ldap.ValidateUserAsync("alice", "Password123!");
if (isValid && userInfo is not null)
{
Console.WriteLine($"DisplayName: {userInfo.DisplayName}");
Console.WriteLine($"Email: {userInfo.Email}");
}
Find a Single User
var user = await ldap.FindUserAsync("alice");
if (user is not null)
{
Console.WriteLine($"SamAccountName: {user.SamAccountName}");
Console.WriteLine($"DN: {user.Dn}");
}
Search Users
var users = await ldap.GetUsersAsync("alice");
foreach (var item in users)
{
Console.WriteLine($"{item.DisplayName} ({item.Email})");
}
Search in a Specific OU with Custom Bind Credentials
var customCreds = new LdapCredentials
{
BindDn = "readonly.user",
BindCredentials = "ReadonlyPassword123!"
};
var usersInOu = await ldap.GetUsersAsync(
"alice",
ldapCredentials: customCreds,
searchBase: "OU=Sales,DC=example,DC=com");
Advanced Filter Search (Cross-Provider)
ILdap ldapContract = ldap;
var users = await ldapContract.SearchUsersByFilterAsync(
"(&(objectClass=person)(department=IT)(mail=*))",
searchBase: "DC=example,DC=com");
Active Directory Specific: Get DirectoryEntry
using var entry = ldap.GetEntryByUsername("alice");
var nativeObject = entry.NativeObject;
var properties = entry.Properties;
Notes
- This implementation is intended for Windows environments using
System.DirectoryServices. - In .NET 5+, the implementation is marked with
[SupportedOSPlatform("windows")]. - When
Security = true, the client uses LDAPS (LDAPS://) and secure bind options. SearchFilteris used by bothFindUserAsyncandGetUsersAsync; using{0}placeholder is recommended.SearchUsersByFilterAsyncprovides provider-agnostic advanced raw-filter queries.- If
SearchFilterformat is invalid, the implementation falls back to a default user filter. - Input value in user search is escaped before building LDAP filter to reduce malformed/injection risk.
- Bind username normalization supports existing
domain\\user, UPN (user@domain), and full DN forms. - If
LdapConfig.Urlis empty, Active Directory provider attempts domain controller auto-discovery. - Convenience constructor overloads can auto-fill missing
DomainandSearchBasedefaults.
Key User Properties (AdUserInfo)
DisplayName,SamAccountName,Upn,DnEmail,TelephoneNumber,Mobile,Department,TitleCompany,Manager,WhenCreated,Status,PwdLastSetMemberOf,ProfilePath,HomeDirectory,ExtensionAttribute1
Dependencies
- System.DirectoryServices
- System.DirectoryServices.AccountManagement
- Linger.Ldap.Contracts
Related Packages
- Linger.Ldap.Contracts: core LDAP interfaces and data models
- Linger.Ldap.Novell: cross-platform LDAP implementation based on Novell 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Linger.Ldap.Contracts (>= 1.4.0)
- Linger.Utils (>= 1.4.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Options (>= 10.0.7)
- System.DirectoryServices (>= 10.0.7)
- System.DirectoryServices.AccountManagement (>= 10.0.7)
-
net10.0
- Linger.Ldap.Contracts (>= 1.4.0)
- Linger.Utils (>= 1.4.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Options (>= 10.0.7)
- System.DirectoryServices (>= 10.0.7)
- System.DirectoryServices.AccountManagement (>= 10.0.7)
-
net8.0
- Linger.Ldap.Contracts (>= 1.4.0)
- Linger.Utils (>= 1.4.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Options (>= 10.0.7)
- System.DirectoryServices (>= 10.0.7)
- System.DirectoryServices.AccountManagement (>= 10.0.7)
-
net9.0
- Linger.Ldap.Contracts (>= 1.4.0)
- Linger.Utils (>= 1.4.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Options (>= 10.0.7)
- System.DirectoryServices (>= 10.0.7)
- System.DirectoryServices.AccountManagement (>= 10.0.7)
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.4.0 | 66 | 5/6/2026 |
| 1.3.3-preview | 75 | 5/5/2026 |
| 1.3.2-preview | 86 | 4/29/2026 |
| 1.3.1-preview | 89 | 4/28/2026 |
| 1.3.0-preview | 82 | 4/27/2026 |
| 1.2.0-preview | 102 | 3/29/2026 |
| 1.1.0 | 119 | 2/4/2026 |
| 1.0.3-preview | 116 | 1/9/2026 |
| 1.0.2-preview | 108 | 1/8/2026 |
| 1.0.0 | 313 | 11/12/2025 |
| 1.0.0-preview2 | 189 | 11/6/2025 |
| 1.0.0-preview1 | 181 | 11/5/2025 |
| 0.9.9 | 170 | 10/16/2025 |
| 0.9.8 | 173 | 10/14/2025 |
| 0.9.7-preview | 162 | 10/13/2025 |
| 0.9.6-preview | 148 | 10/12/2025 |
| 0.9.5 | 146 | 9/28/2025 |
| 0.9.4-preview | 167 | 9/25/2025 |
| 0.9.3-preview | 192 | 9/22/2025 |
| 0.9.1-preview | 297 | 9/16/2025 |
Loading failed