Implemented /Users/Delete endpoint, removed unnecessary objectClasses

This commit is contained in:
2025-09-28 20:08:37 +02:00
parent 0c592b14f6
commit db342d0d28
3 changed files with 8 additions and 6 deletions
-2
View File
@@ -3,8 +3,6 @@
## users ## users
- ObjectClass: - ObjectClass:
- inetOrgPerson - inetOrgPerson
- person
- top
- cn = Name - cn = Name
- sn = Surname - sn = Surname
- title = title (e.g. "Dr.", "Herr", "Frau", etc.) - title = title (e.g. "Dr.", "Herr", "Frau", etc.)
+2 -4
View File
@@ -24,13 +24,13 @@ public class UsersController : Controller
} }
[HttpGet("Delete")] [HttpGet("Delete")]
public async Task<bool> Delete(string dn) public async Task<bool> Delete(string uid)
{ {
return await Task.Run(() => return await Task.Run(() =>
{ {
try try
{ {
_ldap.DeleteObjectByDn(dn); _ldap.DeleteUser(uid);
return true; return true;
} }
catch (Exception) catch (Exception)
@@ -52,8 +52,6 @@ public class UsersController : Controller
LdapAttributeSet attributeSet = new LdapAttributeSet LdapAttributeSet attributeSet = new LdapAttributeSet
{ {
new LdapAttribute("objectClass", "inetOrgPerson"), new LdapAttribute("objectClass", "inetOrgPerson"),
new LdapAttribute("objectClass", "person"),
new LdapAttribute("objectClass", "top"),
new LdapAttribute("cn", cn), new LdapAttribute("cn", cn),
new LdapAttribute("sn", sn), new LdapAttribute("sn", sn),
new LdapAttribute("title", title), new LdapAttribute("title", title),
+6
View File
@@ -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) public async void DeleteObjectByDn(string dn)
{ {
await _conn.DeleteAsync(dn); await _conn.DeleteAsync(dn);