Compare commits

...

3 Commits

Author SHA1 Message Date
Developer 02
f0e82b4210 Merge branch 'master' of http://git.dd:3000/AppStd/DigitalData.ActiveDirectory 2025-08-06 18:57:25 +02:00
Developer 02
cf0741ea8a refactor(ActiveDirectoryOptions): Umbenennen in DirectoryEntryQuery 2025-08-06 18:01:07 +02:00
Developer 02
6215642fcf feat(ActiveDirectoryOptions): AuthenticationType-Eigenschaft hinzufügen
- AuthenticationType-Eigenschaft zu SearchRoot in DirectorySearchQueryHandler hinzufügen
2025-08-06 17:43:39 +02:00
7 changed files with 28 additions and 23 deletions

View File

@@ -12,7 +12,7 @@ builder.Services.AddSwaggerGen();
builder.Services.AddActiveDirectory(options =>
{
options.ConfigActiveDirectory(builder.Configuration.GetSection("ActiveDirectory"));
options.ConfigRootDirectoryEntry(builder.Configuration.GetSection("RootDirectoryEntry"));
options.LPLicenseKey = builder.Configuration["LPLicense"];
});

View File

@@ -6,7 +6,7 @@
}
},
"AllowedHosts": "*",
"ActiveDirectory": {
"RootDirectoryEntry": {
"Path": "LDAP://DD-VMP01-DC01/DC=dd-gan,DC=local,DC=digitaldata,DC=works",
"Username": "FABRIK19-User01",
"Password": "9bWOr0UGuHn_7VkC"

View File

@@ -1,10 +0,0 @@
namespace DigitalData.ActiveDirectory;
public class ActiveDirectoryOptions
{
public string Path { get; set; } = null!;
public string Username { get; set; } = null!;
public string Password { get; set; } = null!;
}

View File

@@ -25,12 +25,12 @@ public static class DependencyInjection
});
if (!cOptions.IsADConfigured)
services.Configure<ActiveDirectoryOptions>(_ => { });
services.Configure<DirectoryEntryQuery>(_ => { });
return services;
}
public class ADConfigurationOptions : ActiveDirectoryOptions
public class ADConfigurationOptions
{
private readonly IServiceCollection _services;
@@ -54,8 +54,8 @@ public static class DependencyInjection
IsADConfigured = true;
}
public void ConfigActiveDirectory(IConfiguration config) => EnsureSingleMappingConfiguration(() => _services.Configure<ActiveDirectoryOptions>(config));
public void ConfigRootDirectoryEntry(IConfiguration config) => EnsureSingleMappingConfiguration(() => _services.Configure<DirectoryEntryQuery>(config));
public void ConfigActiveDirectory(Action<ActiveDirectoryOptions> options) => EnsureSingleMappingConfiguration(() => _services.Configure(options));
public void ConfigRootDirectoryEntry(Action<DirectoryEntryQuery> options) => EnsureSingleMappingConfiguration(() => _services.Configure(options));
}
}

View File

@@ -0,0 +1,16 @@
using MediatR;
using System.DirectoryServices;
namespace DigitalData.ActiveDirectory;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>")]
public class DirectoryEntryQuery: IRequest
{
public string Path { get; set; } = null!;
public string Username { get; set; } = null!;
public string Password { get; set; } = null!;
public IEnumerable<AuthenticationTypes> AuthenticationType { get; set; } = new List<AuthenticationTypes>() { AuthenticationTypes.None };
}

View File

@@ -9,9 +9,7 @@ namespace DigitalData.ActiveDirectory;
public record DirectorySearchQuery(string? Filter = null, SearchScope Scope = SearchScope.Subtree, int SizeLimit = 5000, params string[] Property)
: IRequest<IEnumerable<ResultPropertyCollection>>
{
public record Root(string Path, string? Username = null, string? Password = null);
public Root? SearchRoot { get; set; }
public DirectoryEntryQuery? SearchRoot { get; set; }
public Action<DirectorySearcher>? AfterInit { get; set; }
}
@@ -19,11 +17,11 @@ public record DirectorySearchQuery(string? Filter = null, SearchScope Scope = Se
[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>")]
public class DirectorySearchQueryHandler : IRequestHandler<DirectorySearchQuery, IEnumerable<ResultPropertyCollection>>
{
private readonly IOptions<ActiveDirectoryOptions> _options;
private readonly IOptions<DirectoryEntryQuery> _options;
private readonly IMapper _mapper;
public DirectorySearchQueryHandler(IOptions<ActiveDirectoryOptions> options, IMapper mapper)
public DirectorySearchQueryHandler(IOptions<DirectoryEntryQuery> options, IMapper mapper)
{
_options = options;
_mapper = mapper;
@@ -40,7 +38,8 @@ public class DirectorySearchQueryHandler : IRequestHandler<DirectorySearchQuery,
{
Path = _options.Value.Path,
Username = _options.Value.Username,
Password = _options.Value.Password
Password = _options.Value.Password,
AuthenticationType = _options.Value.AuthenticationType.Aggregate((a, b) => a | b)
};
request.AfterInit?.Invoke(searcher);

View File

@@ -9,6 +9,6 @@ public class MappingProfile : Profile
public MappingProfile()
{
CreateMap<DirectorySearchQuery, DirectorySearcher>();
CreateMap<DirectorySearchQuery.Root, DirectoryEntry>();
CreateMap<DirectoryEntry, DirectoryEntry>();
}
}