mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 15:01:56 +00:00
Added filter to /Users/Index to filter out fields
This commit is contained in:
@@ -17,16 +17,25 @@ public class UsersController : Controller
|
||||
}
|
||||
|
||||
[HttpGet("Index")]
|
||||
public async Task<IEnumerable<Dictionary<string, string>>> Index(string? uid = null)
|
||||
public async Task<IEnumerable<Dictionary<string, string>>> Index(UsersIndexRequestModel requestModel)
|
||||
{
|
||||
string? uid = requestModel.Uid;
|
||||
List<string> attributes = ["cn", "sn", "title", "uid", "jpegPhoto", "userPassword", "description"];
|
||||
if (!requestModel.Cn) attributes.Remove("cn");
|
||||
if (!requestModel.Sn) attributes.Remove("sn");
|
||||
if (!requestModel.Title) attributes.Remove("title");
|
||||
if (!requestModel.JpegPhoto) attributes.Remove("jpegPhoto");
|
||||
if (!requestModel.UserPassword) attributes.Remove("userPassword");
|
||||
if (!requestModel.Description) attributes.Remove("description");
|
||||
|
||||
if (uid is null)
|
||||
{
|
||||
var users = await _ldap.ListUsersAsync();
|
||||
var users = await _ldap.ListUsersAsync([.. attributes]);
|
||||
return users;
|
||||
}
|
||||
else
|
||||
{
|
||||
var user = await _ldap.GetUserByUidAsync(uid);
|
||||
var user = await _ldap.GetUserByUidAsync(uid, [.. attributes]);
|
||||
return [user];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user