Created src folder, created docs folder, added Pflichtenheft

This commit is contained in:
2025-09-27 14:31:29 +02:00
parent b7319c1ffa
commit cc1f55658f
85 changed files with 178 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
using Berufsschule_HAM.Models;
using Novell.Directory.Ldap;
using Berufsschule_HAM.Services;
[Route("[controller]")]
public class AssetsController : Controller
{
private readonly LdapService _ldap;
public AssetsController(LdapService ldap)
{
_ldap = ldap ?? throw new ArgumentNullException(nameof(ldap));
}
// GET: /Assets
[HttpGet("Index")]
public async Task<IEnumerable<Dictionary<string, string>>> Index()
{
var list = await _ldap.ListDeviceAsync();
return list;
}
}

View File

@@ -0,0 +1,19 @@
// Controllers/LocationsController.cs
using Berufsschule_HAM.Services;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
[Route("[controller]")]
public class LocationsController : Controller
{
private readonly LdapService _ldap;
public LocationsController(LdapService ldap) => _ldap = ldap;
[HttpGet("Index")]
public async Task<IEnumerable<Dictionary<string, string>>> Index()
{
IEnumerable<Dictionary<string, string>> list = await _ldap.ListLocationsAsync();
return list;
}
}

View File

@@ -0,0 +1,62 @@
// Controllers/UsersController.cs
using Berufsschule_HAM.Services;
using Microsoft.AspNetCore.Mvc;
using Novell.Directory.Ldap;
using System.Threading.Tasks;
[Route("[controller]")]
public class UsersController : Controller
{
private readonly LdapService _ldap;
public UsersController(LdapService ldap) => _ldap = ldap;
[HttpGet("Index")]
public async Task<IEnumerable<Dictionary<string, string>>> Index()
{
var users = await _ldap.ListUsersAsync();
return users;
}
[HttpGet("Delete")]
public async Task<bool> Delete(string dn)
{
return await Task.Run(() =>
{
try
{
_ldap.DeleteObjectByDn(dn);
return true;
}
catch (Exception)
{
return false;
}
});
}
[HttpGet("Create")]
public async Task<bool> Create(string cn, string sn, string userPassword)
{
// return await new Task<bool>(() =>
// {
try
{
LdapAttributeSet attributeSet = [];
attributeSet.Add(new LdapAttribute("objectClass", "organizationalPerson"));
attributeSet.Add(new LdapAttribute("objectClass", "person"));
//attributeSet.Add(new LdapAttribute("ou", "users"));
attributeSet.Add(new LdapAttribute("objectClass", "top"));
attributeSet.Add(new LdapAttribute("cn", cn));
attributeSet.Add(new LdapAttribute("sn", sn));
attributeSet.Add(new LdapAttribute("userPassword", userPassword));
_ldap.CreateUser(attributeSet);
return true;
}
catch (Exception ex)
{
return false;
}
// });
}
}