Implementierung des Imports von Benutzern und Gruppen aus Active Directory im Angular-Frontend.
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
using DigitalData.Core.Contracts.Application;
|
||||
using DigitalData.UserManager.Application.DTOs.Group;
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
using DigitalData.UserManager.Infrastructure.Contracts;
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
|
||||
namespace DigitalData.UserManager.Application.Contracts
|
||||
{
|
||||
public interface IGroupService : ICRUDService<IGroupRepository, GroupCreateDto, GroupReadDto, GroupUpdateDto, Group, int>
|
||||
{
|
||||
Task<IServiceResult<int>> CreateAsync(ADGroup adGroup);
|
||||
Task<IServiceResult<int>> CreateAsync(DirectoryGroupDto adGroup);
|
||||
}
|
||||
}
|
||||
@@ -14,5 +14,7 @@ namespace DigitalData.UserManager.Application.Contracts
|
||||
Task<IServiceResult<IEnumerable<UserReadDto>>> ReadByGroupIdAsync(int groupId);
|
||||
|
||||
Task<IServiceResult<IEnumerable<UserReadDto>>> ReadUnassignedByGroupIdAsync(int groupId);
|
||||
|
||||
Task<IServiceResult<int>> CreateAsync(UserPrincipalDto upDto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace DigitalData.UserManager.Application.DTOs.Group
|
||||
{
|
||||
public record DirectoryGroupDto
|
||||
(
|
||||
IEnumerable<string> Samaccountname
|
||||
//public string Name { get; set; }
|
||||
//public string ObjectSid { get; set; }
|
||||
//public string ObjectCategory { get; set; }
|
||||
//public int SamAccountType { get; set; }
|
||||
//public string DistinguishedName { get; set; }
|
||||
//public int InstanceType { get; set; }
|
||||
//public string CN { get; set; }
|
||||
//public string ObjectClass { get; set; }
|
||||
//public DateTime WhenChanged { get; set; }
|
||||
//public Guid ObjectGuid { get; set; }
|
||||
//public long UsnCreated { get; set; }
|
||||
//public int? GroupType { get; set; }
|
||||
//public DateTime? DsCorePropagationData { get; set; }
|
||||
//public int? AdminCount { get; set; }
|
||||
//public int? SystemFlags { get; set; }
|
||||
//public string Member { get; set; }
|
||||
//public string AdsPath { get; set; }
|
||||
//public long UsnChanged { get; set; }
|
||||
//public DateTime WhenCreated { get; set; }
|
||||
//public string Description { get; set; }
|
||||
//public bool? IsCriticalSystemObject { get; set; }
|
||||
);
|
||||
}
|
||||
@@ -1,17 +1,18 @@
|
||||
namespace DigitalData.UserManager.Application.DTOs.User
|
||||
{
|
||||
public record UserCreateDto(
|
||||
string Prename,
|
||||
string? Name,
|
||||
string? Username,
|
||||
string? Shortname,
|
||||
string? Email,
|
||||
string? Language,
|
||||
string? Comment,
|
||||
bool? Deleted,
|
||||
string? DateFormat,
|
||||
string? AddedWho,
|
||||
string? ChangedWho,
|
||||
bool Active
|
||||
);
|
||||
public record class UserCreateDto
|
||||
{
|
||||
public string? Prename { get; init; }
|
||||
public string? Name { get; init; }
|
||||
public string? Username { get; init; }
|
||||
public string? Shortname { get; init; }
|
||||
public string? Email { get; init; }
|
||||
public string Language { get; init; } = "de-DE";
|
||||
public string? Comment { get; init; }
|
||||
public bool? Deleted { get; init; }
|
||||
public string DateFormat { get; init; } = "dd.MM.yyyy";
|
||||
public string AddedWho { get; init; } = "DEFAULT";
|
||||
public string? ChangedWho { get; init; }
|
||||
public bool Active { get; init; } = true;
|
||||
}
|
||||
}
|
||||
@@ -2,31 +2,33 @@
|
||||
{
|
||||
public record UserPrincipalDto
|
||||
(
|
||||
Guid Guid,
|
||||
string SId,
|
||||
string EmployeeId,
|
||||
string SamAccountName,
|
||||
string GivenName,
|
||||
string MiddleName,
|
||||
string? MiddleName,
|
||||
string Surname,
|
||||
string EmailAddress,
|
||||
string VoiceTelephoneNumber,
|
||||
DateTime? AccountExpirationDate,
|
||||
DateTime? AccountLockoutTime,
|
||||
bool AllowReversiblePasswordEncryption,
|
||||
int BadLogonCount,
|
||||
bool DelegationPermitted,
|
||||
bool? Enabled,
|
||||
string HomeDirectory,
|
||||
string HomeDrive,
|
||||
DateTime? LastBadPasswordAttempt,
|
||||
DateTime? LastLogon,
|
||||
DateTime? LastPasswordSet,
|
||||
bool PasswordNeverExpires,
|
||||
bool PasswordNotRequired,
|
||||
byte[] PermittedLogonTimes,
|
||||
bool SmartcardLogonRequired,
|
||||
bool UserCannotChangePassword
|
||||
string? AddedWho,
|
||||
string? DateFormat
|
||||
// Guid Guid,
|
||||
// string SId,
|
||||
// string EmployeeId,
|
||||
// string VoiceTelephoneNumber,
|
||||
// DateTime? AccountExpirationDate,
|
||||
// DateTime? AccountLockoutTime,
|
||||
// bool AllowReversiblePasswordEncryption,
|
||||
// int BadLogonCount,
|
||||
// bool DelegationPermitted,
|
||||
// bool? Enabled,
|
||||
// string HomeDirectory,
|
||||
// string HomeDrive,
|
||||
// DateTime? LastBadPasswordAttempt,
|
||||
// DateTime? LastLogon,
|
||||
// DateTime? LastPasswordSet,
|
||||
// bool PasswordNeverExpires,
|
||||
// bool PasswordNotRequired,
|
||||
// byte[] PermittedLogonTimes,
|
||||
// bool SmartcardLogonRequired,
|
||||
// bool UserCannotChangePassword
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace DigitalData.UserManager.Application.MappingProfiles
|
||||
CreateMap<GroupReadDto, Group>();
|
||||
CreateMap<GroupUpdateDto, Group>();
|
||||
|
||||
CreateMap<ADGroup, Group>()
|
||||
CreateMap<DirectoryGroupDto, Group>()
|
||||
.ForMember(group => group.EcmFkId, opt => opt.MapFrom(adGroup => 1))
|
||||
.ForMember(group => group.AdSync, opt => opt.MapFrom(adGroup => true))
|
||||
.ForMember(group => group.Internal, opt => opt.MapFrom(adGroup => false))
|
||||
|
||||
@@ -15,6 +15,12 @@ namespace DigitalData.UserManager.Application.MappingProfiles
|
||||
CreateMap<UserCreateDto, User>();
|
||||
CreateMap<UserReadDto, User>();
|
||||
CreateMap<UserUpdateDto, User>();
|
||||
|
||||
CreateMap<UserPrincipalDto, User>()
|
||||
.ForMember(user => user.Name, opt => opt.MapFrom(upDto => upDto.Surname))
|
||||
.ForMember(user => user.Prename, opt => opt.MapFrom(upDto => upDto.GivenName))
|
||||
.ForMember(user => user.Username, opt => opt.MapFrom(upDto => upDto.SamAccountName))
|
||||
.ForMember(user => user.Email, opt => opt.MapFrom(upDto => upDto.EmailAddress));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ namespace DigitalData.UserManager.Application
|
||||
{
|
||||
UserNotFound,
|
||||
GroupNotFound,
|
||||
GroupAlreadyExists
|
||||
GroupAlreadyExists,
|
||||
UserAlreadyExists
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace DigitalData.UserManager.Application.Services
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<IServiceResult<int>> CreateAsync(ADGroup adGroup)
|
||||
public async Task<IServiceResult<int>> CreateAsync(DirectoryGroupDto adGroup)
|
||||
{
|
||||
var group = _mapper.MapOrThrow<Group>(adGroup);
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace DigitalData.UserManager.Application.Services
|
||||
{
|
||||
public class UserService : CRUDService<IUserRepository, UserCreateDto, UserReadDto, UserUpdateDto, User, int>, IUserService
|
||||
{
|
||||
public UserService(IModuleService moduleService, IUserRepository repository, IKeyTranslationService translationService, IMapper mapper) : base(repository, translationService, mapper)
|
||||
public UserService(IUserRepository repository, IKeyTranslationService translationService, IMapper mapper) : base(repository, translationService, mapper)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -42,5 +42,19 @@ namespace DigitalData.UserManager.Application.Services
|
||||
IEnumerable<UserReadDto> readDTOs = _mapper.MapOrThrow<IEnumerable<UserReadDto>>(users);
|
||||
return Successful(readDTOs);
|
||||
}
|
||||
|
||||
public async Task<IServiceResult<int>> CreateAsync(UserPrincipalDto upDto)
|
||||
{
|
||||
var user = _mapper.MapOrThrow<User>(upDto);
|
||||
|
||||
if (await HasEntity(user.Guid))
|
||||
return Failed<int>(MessageKey.UserAlreadyExists.ToString());
|
||||
|
||||
var createdUser = await _repository.CreateAsync(user);
|
||||
if (createdUser is null)
|
||||
return Failed<int>();
|
||||
else
|
||||
return Successful(KeyValueOf(createdUser));
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
dba0a8f681b3418fb35a3068cfbc370fa3c25506
|
||||
c497a415ad8663b537bfca6b9097d6da9018430d
|
||||
|
||||
@@ -43,8 +43,6 @@ E:\TekH\Visual Studio\DDWeb\DigitalData.UserManager\DigitalData.UserManager.Appl
|
||||
E:\TekH\Visual Studio\DDWeb\DigitalData.UserManager\DigitalData.UserManager.Application\bin\Debug\net7.0\DigitalData.Core.Contracts.dll
|
||||
E:\TekH\Visual Studio\DDWeb\DigitalData.UserManager\DigitalData.UserManager.Application\bin\Debug\net7.0\DigitalData.Core.Contracts.pdb
|
||||
E:\TekH\Visual Studio\DDWeb\DigitalData.UserManager\DigitalData.UserManager.Application\bin\Debug\net7.0\DigitalData.Core.Application.dll
|
||||
E:\TekH\Visual Studio\DDWeb\DigitalData.UserManager\DigitalData.UserManager.Application\bin\Debug\net7.0\DigitalData.Core.Attributes.dll
|
||||
E:\TekH\Visual Studio\DDWeb\DigitalData.UserManager\DigitalData.UserManager.Application\bin\Debug\net7.0\DigitalData.Core.Infrastructure.dll
|
||||
E:\TekH\Visual Studio\DDWeb\DigitalData.UserManager\DigitalData.UserManager.Application\bin\Debug\net7.0\DigitalData.Core.Application.pdb
|
||||
E:\TekH\Visual Studio\DDWeb\DigitalData.UserManager\DigitalData.UserManager.Application\bin\Debug\net7.0\DigitalData.Core.Attributes.pdb
|
||||
E:\TekH\Visual Studio\DDWeb\DigitalData.UserManager\DigitalData.UserManager.Application\bin\Debug\net7.0\DigitalData.Core.Infrastructure.pdb
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user