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
|
## 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.)
|
||||||
|
|||||||
@@ -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),
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user