Fixed updating asset to empty location only clientside

This commit is contained in:
2025-10-26 09:22:48 +01:00
parent 82ec15a001
commit 2957800876
2 changed files with 17 additions and 0 deletions

View File

@@ -173,6 +173,10 @@ public class AssetsController : Controller
{ {
await _ldap.UpdateAsset(cn, "l", requestModel.Location); await _ldap.UpdateAsset(cn, "l", requestModel.Location);
} }
else
{
await _ldap.DeleteAttribute(_ldap.AssetsBaseDn, "cn", cn, "l");
}
if (requestModel.Name is not null) if (requestModel.Name is not null)
{ {
await _ldap.UpdateAsset(cn, "name", requestModel.Name); await _ldap.UpdateAsset(cn, "name", requestModel.Name);

View File

@@ -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) public async Task DeleteObjectByDnAsync(string dn)
{ {
await _conn.DeleteAsync(dn); await _conn.DeleteAsync(dn);