refactor(ActiveDirectoryOptions): Umbenennen in DirectoryEntryQuery
This commit is contained in:
parent
6215642fcf
commit
cf0741ea8a
@ -12,7 +12,7 @@ builder.Services.AddSwaggerGen();
|
|||||||
|
|
||||||
builder.Services.AddActiveDirectory(options =>
|
builder.Services.AddActiveDirectory(options =>
|
||||||
{
|
{
|
||||||
options.ConfigActiveDirectory(builder.Configuration.GetSection("ActiveDirectory"));
|
options.ConfigRootDirectoryEntry(builder.Configuration.GetSection("RootDirectoryEntry"));
|
||||||
options.LPLicenseKey = builder.Configuration["LPLicense"];
|
options.LPLicenseKey = builder.Configuration["LPLicense"];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"ActiveDirectory": {
|
"RootDirectoryEntry": {
|
||||||
"Path": "LDAP://DD-VMP01-DC01/DC=dd-gan,DC=local,DC=digitaldata,DC=works",
|
"Path": "LDAP://DD-VMP01-DC01/DC=dd-gan,DC=local,DC=digitaldata,DC=works",
|
||||||
"Username": "FABRIK19-User01",
|
"Username": "FABRIK19-User01",
|
||||||
"Password": "9bWOr0UGuHn_7VkC"
|
"Password": "9bWOr0UGuHn_7VkC"
|
||||||
|
|||||||
@ -25,12 +25,12 @@ public static class DependencyInjection
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!cOptions.IsADConfigured)
|
if (!cOptions.IsADConfigured)
|
||||||
services.Configure<ActiveDirectoryOptions>(_ => { });
|
services.Configure<DirectoryEntryQuery>(_ => { });
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ADConfigurationOptions : ActiveDirectoryOptions
|
public class ADConfigurationOptions
|
||||||
{
|
{
|
||||||
private readonly IServiceCollection _services;
|
private readonly IServiceCollection _services;
|
||||||
|
|
||||||
@ -54,8 +54,8 @@ public static class DependencyInjection
|
|||||||
IsADConfigured = true;
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,9 +1,10 @@
|
|||||||
using System.DirectoryServices;
|
using MediatR;
|
||||||
|
using System.DirectoryServices;
|
||||||
|
|
||||||
namespace DigitalData.ActiveDirectory;
|
namespace DigitalData.ActiveDirectory;
|
||||||
|
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>")]
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>")]
|
||||||
public class ActiveDirectoryOptions
|
public class DirectoryEntryQuery: IRequest
|
||||||
{
|
{
|
||||||
public string Path { get; set; } = null!;
|
public string Path { get; set; } = null!;
|
||||||
|
|
||||||
@ -9,9 +9,7 @@ namespace DigitalData.ActiveDirectory;
|
|||||||
public record DirectorySearchQuery(string? Filter = null, SearchScope Scope = SearchScope.Subtree, int SizeLimit = 5000, params string[] Property)
|
public record DirectorySearchQuery(string? Filter = null, SearchScope Scope = SearchScope.Subtree, int SizeLimit = 5000, params string[] Property)
|
||||||
: IRequest<IEnumerable<ResultPropertyCollection>>
|
: IRequest<IEnumerable<ResultPropertyCollection>>
|
||||||
{
|
{
|
||||||
public record Root(string Path, string? Username = null, string? Password = null);
|
public DirectoryEntryQuery? SearchRoot { get; set; }
|
||||||
|
|
||||||
public Root? SearchRoot { get; set; }
|
|
||||||
|
|
||||||
public Action<DirectorySearcher>? AfterInit { 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>")]
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>")]
|
||||||
public class DirectorySearchQueryHandler : IRequestHandler<DirectorySearchQuery, IEnumerable<ResultPropertyCollection>>
|
public class DirectorySearchQueryHandler : IRequestHandler<DirectorySearchQuery, IEnumerable<ResultPropertyCollection>>
|
||||||
{
|
{
|
||||||
private readonly IOptions<ActiveDirectoryOptions> _options;
|
private readonly IOptions<DirectoryEntryQuery> _options;
|
||||||
|
|
||||||
private readonly IMapper _mapper;
|
private readonly IMapper _mapper;
|
||||||
|
|
||||||
public DirectorySearchQueryHandler(IOptions<ActiveDirectoryOptions> options, IMapper mapper)
|
public DirectorySearchQueryHandler(IOptions<DirectoryEntryQuery> options, IMapper mapper)
|
||||||
{
|
{
|
||||||
_options = options;
|
_options = options;
|
||||||
_mapper = mapper;
|
_mapper = mapper;
|
||||||
|
|||||||
@ -9,6 +9,6 @@ public class MappingProfile : Profile
|
|||||||
public MappingProfile()
|
public MappingProfile()
|
||||||
{
|
{
|
||||||
CreateMap<DirectorySearchQuery, DirectorySearcher>();
|
CreateMap<DirectorySearchQuery, DirectorySearcher>();
|
||||||
CreateMap<DirectorySearchQuery.Root, DirectoryEntry>();
|
CreateMap<DirectoryEntry, DirectoryEntry>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user