Merge pull request #37 from LD-Reborn/7-feature-crud---users-delete

Implemented /Users/Delete endpoint, removed unnecessary objectClasses
This commit is contained in:
LD50
2025-09-28 20:09:04 +02:00
committed by GitHub
3 changed files with 8 additions and 6 deletions

View File

@@ -3,8 +3,6 @@
## users
- ObjectClass:
- inetOrgPerson
- person
- top
- cn = Name
- sn = Surname
- title = title (e.g. "Dr.", "Herr", "Frau", etc.)

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);