mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Added Assets Delete CRUD element
This commit is contained in:
@@ -15,11 +15,28 @@ public class AssetsController : Controller
|
|||||||
_ldap = ldap ?? throw new ArgumentNullException(nameof(ldap));
|
_ldap = ldap ?? throw new ArgumentNullException(nameof(ldap));
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: /Assets
|
|
||||||
[HttpGet("Index")]
|
[HttpGet("Index")]
|
||||||
public async Task<IEnumerable<Dictionary<string, string>>> Index()
|
public async Task<IEnumerable<Dictionary<string, string>>> Index()
|
||||||
{
|
{
|
||||||
var list = await _ldap.ListDeviceAsync();
|
var list = await _ldap.ListDeviceAsync();
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("Delete")]
|
||||||
|
public async Task<bool> Delete(string cn)
|
||||||
|
{
|
||||||
|
if (cn is null) { return false; }
|
||||||
|
return await Task.Run(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_ldap.DeleteAsset(cn);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -269,6 +269,12 @@ public partial class LdapService : IDisposable
|
|||||||
DeleteObjectByDn(dn);
|
DeleteObjectByDn(dn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DeleteAsset(string cn)
|
||||||
|
{
|
||||||
|
string dn = PrependRDN($"cn={cn}", AssetsBaseDn);
|
||||||
|
DeleteObjectByDn(dn);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task UpdateUser(string uid, string attributeName, string attributeValue)
|
public async Task UpdateUser(string uid, string attributeName, string attributeValue)
|
||||||
{
|
{
|
||||||
await UpdateObject(UsersBaseDn, "uid", uid, attributeName, attributeValue);
|
await UpdateObject(UsersBaseDn, "uid", uid, attributeName, attributeValue);
|
||||||
|
|||||||
Reference in New Issue
Block a user