mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Added filter by username for /Users/Index, implemented /Users/Update
This commit is contained in:
@@ -55,6 +55,12 @@ public class LdapService : IDisposable
|
||||
return await ListObjectBy(UsersBaseDn, "", ["cn", "sn", "title", "uid", "jpegPhoto", "userPassword", "description"]);
|
||||
}
|
||||
|
||||
public async Task<Dictionary<string, string>> GetUserByUidAsync(string uid)
|
||||
{
|
||||
return (await ListObjectBy(UsersBaseDn, $"uid={uid}", ["cn", "sn", "title", "uid", "jpegPhoto", "userPassword", "description"])).First();
|
||||
}
|
||||
|
||||
|
||||
public async Task<IEnumerable<Dictionary<string, string>>> ListDeviceAsync()
|
||||
{
|
||||
return await ListObjectBy(AssetsBaseDn, "(objectClass=device)", ["CN", "description", "l", "owner", "serialNumber"]);
|
||||
@@ -118,6 +124,24 @@ public class LdapService : IDisposable
|
||||
string dn = PrependRDN($"uid={uid}", UsersBaseDn);
|
||||
DeleteObjectByDn(dn);
|
||||
}
|
||||
public async Task UpdateUser(string uid, string attributeName, string attributeValue)
|
||||
{
|
||||
await ConnectAndBind();
|
||||
string dn = PrependRDN($"uid={uid}", UsersBaseDn);
|
||||
if (attributeName == "uid")
|
||||
{
|
||||
await _conn.RenameAsync(dn, $"uid={attributeValue}", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
var modification = new LdapModification(
|
||||
LdapModification.Replace,
|
||||
new LdapAttribute(attributeName, attributeValue)
|
||||
);
|
||||
await _conn.ModifyAsync(dn, modification);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async void DeleteObjectByDn(string dn)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user