diff --git a/src/Controllers/LocationsController.cs b/src/Controllers/LocationsController.cs index 1d997a6..bdcefc1 100644 --- a/src/Controllers/LocationsController.cs +++ b/src/Controllers/LocationsController.cs @@ -16,4 +16,22 @@ public class LocationsController : Controller return list; } + [HttpGet("Delete")] + public async Task Delete(string cn) + { + if (cn is null) { return false; } + return await Task.Run(() => + { + try + { + _ldap.DeleteLocation(cn); + return true; + } + catch (Exception) + { + return false; + } + }); + } + } diff --git a/src/Services/LdapService.cs b/src/Services/LdapService.cs index 8930cda..c5cb0d7 100644 --- a/src/Services/LdapService.cs +++ b/src/Services/LdapService.cs @@ -261,6 +261,12 @@ public partial class LdapService : IDisposable DeleteObjectByDn(dn); } + public void DeleteLocation(string cn) + { + string dn = PrependRDN($"cn={cn}", LocationsBaseDn); + DeleteObjectByDn(dn); + } + public async Task UpdateUser(string uid, string attributeName, string attributeValue) { await UpdateObject(UsersBaseDn, "uid", uid, attributeName, attributeValue);