Added LDAP migrations, made CreateObject async, moved LdapOptions to Models, fixed user password not hashed on user creation

This commit is contained in:
2025-10-03 16:31:08 +02:00
parent 45b1a44ebe
commit 1f356a807f
7 changed files with 220 additions and 23 deletions

View File

@@ -0,0 +1,16 @@
namespace Berufsschule_HAM.Models;
public class LdapConfig
{
public required string Host { get; set; }
public int Port { get; set; } = 389;
public bool UseSsl { get; set; } = false;
public required string BindDn { get; set; }
public required string BindPassword { get; set; }
public required string BaseDn { get; set; }
public string AssetsOu { get; set; } = "ou=assets";
public string LocationsOu { get; set; } = "ou=locations";
public string UsersOu { get; set; } = "ou=users";
public string GroupsOu { get; set; } = "ou=groups";
public string MigrationsOu { get; set; } = "ou=migrations";
}

View File

@@ -0,0 +1,28 @@
using System.Text.Json;
using Berufsschule_HAM.Exceptions;
namespace Berufsschule_HAM.Models;
public class MigrationModel
{
public int Version { get; set; }
public MigrationModel(Dictionary<string, string> ldapData)
{
string? description = ldapData.GetValueOrDefault("description");
if (description is null)
{
Version = 0;
}
else
{
MigrationDescriptionModel? descriptionModel = JsonSerializer.Deserialize<MigrationDescriptionModel>(description)
?? throw new InvalidMigrationDescriptionModel();
Version = descriptionModel.Version;
}
}
}
public class MigrationDescriptionModel
{
public required int Version { get; set; }
}