From 4b3ad38cc3cf8e11db25494e9a4adc9c3d0befff Mon Sep 17 00:00:00 2001 From: LD-Reborn Date: Sat, 1 Nov 2025 16:59:36 +0100 Subject: [PATCH] Fixed performance issue related to user model retrieval, cleaned up ListUsersAsync() --- src/Controllers/HomeController.cs | 2 +- src/Services/LdapService.cs | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Controllers/HomeController.cs b/src/Controllers/HomeController.cs index 50d2f3e..88106b0 100644 --- a/src/Controllers/HomeController.cs +++ b/src/Controllers/HomeController.cs @@ -77,7 +77,7 @@ public class HomeController : Controller [HttpGet("Users")] public async Task UsersAsync() { - IEnumerable users = await _ldap.ListUsersAsync(); + IEnumerable users = await _ldap.ListUsersAsync([.. _ldap.UsersAttributes.Where(attr => attr != "jpegPhoto" && attr != "userPassword")]); List UserTableViewModels = []; foreach (UserModel user in users) { diff --git a/src/Services/LdapService.cs b/src/Services/LdapService.cs index 6c5e160..1f58ce7 100644 --- a/src/Services/LdapService.cs +++ b/src/Services/LdapService.cs @@ -77,10 +77,7 @@ public partial class LdapService : IDisposable public async Task> ListUsersAsync() { - IEnumerable> users = await ListObjectBy(UsersBaseDn, "", UsersAttributes); - List models = []; - users.ToList().ForEach(x => models.Add(new UserModel(x) {Uid = x["uid"]})); - return models; + return await ListUsersAsync(UsersAttributes); } public async Task GetMigrationVersionAsync()