39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
using DigitalData.Core.Contracts.Application;
|
|
using DigitalData.UserManager.Application.DTOs.User;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace DigitalData.UserManager.API.Controllers
|
|
{
|
|
[Route("api/[controller]")]
|
|
public class DirectoryController : ControllerBase
|
|
{
|
|
private ILogger<DirectoryController> _logger;
|
|
private IDirectoryService _dirService;
|
|
|
|
public DirectoryController(ILogger<DirectoryController> logger, IDirectoryService dirService)
|
|
{
|
|
_logger = logger;
|
|
_dirService = dirService;
|
|
}
|
|
|
|
[HttpGet("Group")]
|
|
public IActionResult GetGroupAd(string? propName = null)
|
|
{
|
|
|
|
if (propName is not null)
|
|
return Ok(_dirService.ReadGroupByPropertyName(propName));
|
|
else
|
|
return Ok(_dirService.ReadAllGroupAsCollection());
|
|
}
|
|
|
|
[HttpGet("User")]
|
|
public IActionResult GetUserByGroupName([FromQuery] string groupName)
|
|
{
|
|
if(groupName is null)
|
|
{
|
|
return BadRequest(_dirService.Failed());
|
|
}
|
|
return Ok(_dirService.ReadUserByGroup<UserPrincipalReadDto>(groupIdentityValue:groupName));
|
|
}
|
|
}
|
|
} |