feat: LdapOptions erstellt anstelle statischer (fest codierter) Konfigurationswerte, LdapOptions und Abhängigkeitsinjektionen dafür hinzugefügt

This commit is contained in:
Developer 02
2024-08-05 14:31:59 +02:00
parent d434a5964b
commit eedc726440
6 changed files with 69 additions and 72 deletions

View File

@@ -12,8 +12,11 @@ namespace DAL.Repositories
{
public class EmployeeToWebAppRepository : BaseRepository<EmployeeToWebApp>
{
public EmployeeToWebAppRepository(WebApiContext context) : base(context)
private readonly LdapManager _ldapManager;
public EmployeeToWebAppRepository(WebApiContext context, LdapManager ldapManager) : base(context)
{
_ldapManager = ldapManager;
}
public async Task<bool> DeleteEmloyeeToWebAppAsync(int webAppId)
@@ -75,24 +78,24 @@ namespace DAL.Repositories
if (department != default && !string.IsNullOrEmpty(department.AdGroupDepartmentName))
{
groupSuffix = $"{webapp.AdWebAppName}_{department.AdGroupDepartmentName}";
if (LdapManager.IsWindreamSuffixGroup(groupSuffix))
if (_ldapManager.IsWindreamSuffixGroup(groupSuffix))
{
if (isAdding) result = LdapManager.AD_AddUserloginToGroup(employee.LoginName, groupSuffix);
else result = LdapManager.AD_RemoveUserFromGroup(employee.LoginName, groupSuffix);
if (isAdding) result = _ldapManager.AD_AddUserloginToGroup(employee.LoginName, groupSuffix);
else result = _ldapManager.AD_RemoveUserFromGroup(employee.LoginName, groupSuffix);
}
}
if (webappRole != default)
{
groupSuffix = $"{webapp.AdWebAppName}_{webappRole.WebAppRoleName}";
if (isAdding) result = LdapManager.AD_AddUserloginToGroup(employee.LoginName, groupSuffix);
else result = LdapManager.AD_RemoveUserFromGroup(employee.LoginName, groupSuffix);
if (isAdding) result = _ldapManager.AD_AddUserloginToGroup(employee.LoginName, groupSuffix);
else result = _ldapManager.AD_RemoveUserFromGroup(employee.LoginName, groupSuffix);
if (LdapManager.IsWindreamAdminGroup(groupSuffix))
if (_ldapManager.IsWindreamAdminGroup(groupSuffix))
{
groupSuffix = $"{webapp.AdWebAppName}_User";
if (isAdding) result = LdapManager.AD_AddUserloginToGroup(employee.LoginName, groupSuffix);
else result = LdapManager.AD_RemoveUserFromGroup(employee.LoginName, groupSuffix);
if (isAdding) result = _ldapManager.AD_AddUserloginToGroup(employee.LoginName, groupSuffix);
else result = _ldapManager.AD_RemoveUserFromGroup(employee.LoginName, groupSuffix);
}
}
}

View File

@@ -12,8 +12,11 @@ namespace DAL.Repositories
{
public class WebAppToDepartmentRepository : BaseRepository<WebAppToDepartment>
{
public WebAppToDepartmentRepository(WebApiContext context) : base(context)
private readonly LdapManager _ldapManager;
public WebAppToDepartmentRepository(WebApiContext context, LdapManager ldapManager) : base(context)
{
_ldapManager = ldapManager;
}
public async Task<List<WebAppToDepartment>> GetListByFilterAsync(EmployeeToWebAppFilter filter, bool asNoTracking = true)
@@ -59,11 +62,11 @@ namespace DAL.Repositories
var isAdding = action == "adding";
var groupSuffix = $"{webapp.AdWebAppName}_{department.AdGroupDepartmentName}";
if (!LdapManager.IsWindreamSuffixGroup(groupSuffix)) return true;
if (!_ldapManager.IsWindreamSuffixGroup(groupSuffix)) return true;
try
{
if (isAdding) result = LdapManager.AD_AddUserloginToGroup(employee.LoginName, groupSuffix);
else result = LdapManager.AD_RemoveUserFromGroup(employee.LoginName, groupSuffix);
if (isAdding) result = _ldapManager.AD_AddUserloginToGroup(employee.LoginName, groupSuffix);
else result = _ldapManager.AD_RemoveUserFromGroup(employee.LoginName, groupSuffix);
}
catch (Exception ex)
{

View File

@@ -12,8 +12,11 @@ namespace DAL.Repositories
{
public class WebAppToWebAppAdditionalRoleRepository : BaseRepository<WebAppToWebAppAdditionalRole>
{
public WebAppToWebAppAdditionalRoleRepository(WebApiContext context) : base(context)
private readonly LdapManager _ldapManager;
public WebAppToWebAppAdditionalRoleRepository(WebApiContext context, LdapManager ldapManager) : base(context)
{
_ldapManager = ldapManager;
}
public async Task<List<WebAppToWebAppAdditionalRole>> GetListByFilterAsync(EmployeeToWebAppFilter filter, bool asNoTracking = true)
@@ -60,8 +63,8 @@ namespace DAL.Repositories
var groupSuffix = $"{webapp.AdWebAppName}_{webappRole.AdWebAppAdditionalRoleName}";
try
{
if (isAdding) result = LdapManager.AD_AddUserloginToGroup(employee.LoginName, groupSuffix);
else result = LdapManager.AD_RemoveUserFromGroup(employee.LoginName, groupSuffix);
if (isAdding) result = _ldapManager.AD_AddUserloginToGroup(employee.LoginName, groupSuffix);
else result = _ldapManager.AD_RemoveUserFromGroup(employee.LoginName, groupSuffix);
}
catch (Exception ex)
{