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

View File

@@ -24,13 +24,13 @@ public class UsersController : Controller
}
[HttpGet("Delete")]
public async Task<bool> Delete(string dn)
public async Task<bool> 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),

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)
{
await _conn.DeleteAsync(dn);