Linger.Ldap.Contracts
0.9.8
See the version list below for details.
dotnet add package Linger.Ldap.Contracts --version 0.9.8
NuGet\Install-Package Linger.Ldap.Contracts -Version 0.9.8
<PackageReference Include="Linger.Ldap.Contracts" Version="0.9.8" />
<PackageVersion Include="Linger.Ldap.Contracts" Version="0.9.8" />
<PackageReference Include="Linger.Ldap.Contracts" />
paket add Linger.Ldap.Contracts --version 0.9.8
#r "nuget: Linger.Ldap.Contracts, 0.9.8"
#:package Linger.Ldap.Contracts@0.9.8
#addin nuget:?package=Linger.Ldap.Contracts&version=0.9.8
#tool nuget:?package=Linger.Ldap.Contracts&version=0.9.8
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:
// 在Program.cs或Startup.cs中配置服务
public void ConfigureServices(IServiceCollection services)
{
// 添加LDAP配置
services.Configure<LdapConfig>(Configuration.GetSection("LdapConfig"));
// 根据具体实现注册LDAP服务
// 针对Active Directory
services.AddScoped<ILdap, Linger.Ldap.ActiveDirectory.Ldap>();
// 或者针对Novell LDAP
// services.AddScoped<ILdap, Linger.Ldap.Novell.Ldap>();
}
appsettings.json配置示例
{
"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"
]
}
}
使用示例
用户身份验证
public class AuthenticationService
{
private readonly ILdap _ldap;
public AuthenticationService(ILdap ldap)
{
_ldap = ldap;
}
public async Task<bool> AuthenticateUserAsync(string username, string password)
{
var (isValid, userInfo) = await _ldap.ValidateUserAsync(username, password);
if (isValid && userInfo != null)
{
// 用户认证成功,可以使用userInfo中的信息
Console.WriteLine($"用户 {userInfo.DisplayName} 认证成功");
return true;
}
return false;
}
}
查找用户信息
public class UserService
{
private readonly ILdap _ldap;
public UserService(ILdap ldap)
{
_ldap = ldap;
}
public async Task<AdUserInfo?> GetUserInfoAsync(string username)
{
return await _ldap.FindUserAsync(username);
}
public async Task<IEnumerable<AdUserInfo>> SearchUsersAsync(string searchTerm)
{
return await _ldap.GetUsersAsync(searchTerm);
}
public async Task<bool> CheckUserExistsAsync(string username)
{
return await _ldap.UserExistsAsync(username);
}
}
支持的实现
库提供了以下LDAP目录服务的实现:
- Linger.Ldap.ActiveDirectory - 针对Microsoft Active Directory的实现
- Linger.Ldap.Novell - 使用Novell 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.6.3 | 131 | 8/5/2026 |
| 1.6.2 | 155 | 8/2/2026 |
| 1.6.0 | 168 | 7/25/2026 |
| 1.5.5 | 166 | 7/23/2026 |
| 1.5.4-preview | 153 | 7/21/2026 |
| 1.5.3-preview | 152 | 7/20/2026 |
| 1.5.2-preview | 148 | 7/19/2026 |
| 1.5.1-preview | 145 | 7/15/2026 |
| 1.5.0-preview | 146 | 7/14/2026 |
| 1.4.4-preview | 165 | 6/16/2026 |
| 1.4.3-preview | 158 | 6/15/2026 |
| 1.4.2 | 180 | 5/20/2026 |
| 1.4.1-preview | 168 | 5/12/2026 |
| 1.4.0 | 168 | 5/6/2026 |
| 1.3.3-preview | 161 | 5/5/2026 |
| 1.3.2-preview | 168 | 4/29/2026 |
| 1.3.1-preview | 158 | 4/28/2026 |
| 1.3.0-preview | 153 | 4/27/2026 |
| 1.2.0-preview | 174 | 3/29/2026 |
| 0.9.8 | 211 | 10/14/2025 |