From db342d0d286606c2a345b4f3ed67003892771e7d Mon Sep 17 00:00:00 2001 From: LD-Reborn Date: Sun, 28 Sep 2025 20:08:37 +0200 Subject: [PATCH] Implemented /Users/Delete endpoint, removed unnecessary objectClasses --- docs/20250928 Object attribute specs.md | 2 -- src/Controllers/UsersController.cs | 6 ++---- src/Services/LdapService.cs | 6 ++++++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/20250928 Object attribute specs.md b/docs/20250928 Object attribute specs.md index 07b0f84..5b10040 100644 --- a/docs/20250928 Object attribute specs.md +++ b/docs/20250928 Object attribute specs.md @@ -3,8 +3,6 @@ ## users - ObjectClass: - inetOrgPerson - - person - - top - cn = Name - sn = Surname - title = title (e.g. "Dr.", "Herr", "Frau", etc.) diff --git a/src/Controllers/UsersController.cs b/src/Controllers/UsersController.cs index bd655ca..7d3516c 100644 --- a/src/Controllers/UsersController.cs +++ b/src/Controllers/UsersController.cs @@ -24,13 +24,13 @@ public class UsersController : Controller } [HttpGet("Delete")] - public async Task Delete(string dn) + public async Task Delete(string uid) { return await Task.Run(() => { try { - _ldap.DeleteObjectByDn(dn); + _ldap.DeleteUser(uid); return true; } catch (Exception) @@ -52,8 +52,6 @@ public class UsersController : Controller LdapAttributeSet attributeSet = new LdapAttributeSet { new LdapAttribute("objectClass", "inetOrgPerson"), - new LdapAttribute("objectClass", "person"), - new LdapAttribute("objectClass", "top"), new LdapAttribute("cn", cn), new LdapAttribute("sn", sn), new LdapAttribute("title", title), diff --git a/src/Services/LdapService.cs b/src/Services/LdapService.cs index f5ebbaf..06d9c17 100644 --- a/src/Services/LdapService.cs +++ b/src/Services/LdapService.cs @@ -113,6 +113,12 @@ public class LdapService : IDisposable }); } + public void DeleteUser(string uid) + { + string dn = PrependRDN($"uid={uid}", UsersBaseDn); + DeleteObjectByDn(dn); + } + public async void DeleteObjectByDn(string dn) { await _conn.DeleteAsync(dn);