mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Implemented /Users/Delete endpoint, removed unnecessary objectClasses
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
## users
|
||||
- ObjectClass:
|
||||
- inetOrgPerson
|
||||
- person
|
||||
- top
|
||||
- cn = Name
|
||||
- sn = Surname
|
||||
- title = title (e.g. "Dr.", "Herr", "Frau", etc.)
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user