From 29578008768d65f0933368912372ebccbcf7b9c6 Mon Sep 17 00:00:00 2001 From: LD-Reborn Date: Sun, 26 Oct 2025 09:22:48 +0100 Subject: [PATCH] Fixed updating asset to empty location only clientside --- src/Controllers/AssetsController.cs | 4 ++++ src/Services/LdapService.cs | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/Controllers/AssetsController.cs b/src/Controllers/AssetsController.cs index f1d670a..afae388 100644 --- a/src/Controllers/AssetsController.cs +++ b/src/Controllers/AssetsController.cs @@ -173,6 +173,10 @@ public class AssetsController : Controller { await _ldap.UpdateAsset(cn, "l", requestModel.Location); } + else + { + await _ldap.DeleteAttribute(_ldap.AssetsBaseDn, "cn", cn, "l"); + } if (requestModel.Name is not null) { await _ldap.UpdateAsset(cn, "name", requestModel.Name); diff --git a/src/Services/LdapService.cs b/src/Services/LdapService.cs index a46fe6d..6c5e160 100644 --- a/src/Services/LdapService.cs +++ b/src/Services/LdapService.cs @@ -429,6 +429,19 @@ public async Task CreateAsset(LdapAttributeSet attributeSet) } } + public async Task DeleteAttribute(string baseDn, string rdnKey, string rdnValue, string attributeName) + { + await ConnectAndBind(); + string dn = PrependRDN($"{rdnKey}={rdnValue}", baseDn); + + var modification = new LdapModification( + LdapModification.Delete, + new LdapAttribute(attributeName) + ); + + await _conn.ModifyAsync(dn, modification); + } + public async Task DeleteObjectByDnAsync(string dn) { await _conn.DeleteAsync(dn);