feat(api): DirSearchRoot-Modell für die Konfiguration der LDAP-Verzeichnissuche und die Konvertierung zu DirectoryEntry hinzufügen

This commit is contained in:
tekh 2025-08-11 10:51:58 +02:00
parent bcdcdd679a
commit f5471a8d01
3 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,22 @@
using DigitalData.Core.Application;
using System.DirectoryServices;
namespace DigitalData.UserManager.API.Models;
[Obsolete("Use ActiveDirectory.API")]
public class DirSearchRoot : DirectorySearchOptions
{
public string Path => $"LDAP://{ServerName}/{Root}";
public string? Username { get; set; }
public string? Password { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>")]
public DirectoryEntry ToDirectoryEntry => new ()
{
Path = Path,
Username = Username,
Password = Password
};
}

View File

@ -82,6 +82,7 @@ try {
builder.ConfigureBySection<DirectorySearchOptions>(); builder.ConfigureBySection<DirectorySearchOptions>();
builder.Services.AddDirectorySearchService(config.GetSection("DirectorySearchOptions")); builder.Services.AddDirectorySearchService(config.GetSection("DirectorySearchOptions"));
builder.Services.Configure<DirSearchRoot>(config.GetSection("DirectorySearchOptions"));
builder.Services.AddJWTService<UserReadDto>(user => new SecurityTokenDescriptor() builder.Services.AddJWTService<UserReadDto>(user => new SecurityTokenDescriptor()
{ {
Claims = user.ToClaimList().ToDictionary(claim => claim.Type, claim => claim.Value as object) Claims = user.ToClaimList().ToDictionary(claim => claim.Type, claim => claim.Value as object)

View File

@ -13,6 +13,8 @@
"DirectorySearchOptions": { "DirectorySearchOptions": {
"ServerName": "DD-VMP01-DC01", "ServerName": "DD-VMP01-DC01",
"Root": "DC=dd-gan,DC=local,DC=digitaldata,DC=works", "Root": "DC=dd-gan,DC=local,DC=digitaldata,DC=works",
"Username": "FABRIK19-User01",
"Password": "9bWOr0UGuHn_7VkC",
"UserCacheExpirationDays": 1, "UserCacheExpirationDays": 1,
"CustomSearchFilters": { "CustomSearchFilters": {
"User": "(&(objectClass=user)(sAMAccountName=*))", "User": "(&(objectClass=user)(sAMAccountName=*))",