67 lines
1.4 KiB
C#
67 lines
1.4 KiB
C#
![]() |
using LdapLoginLib;
|
|||
|
using LdapLoginLib.Models;
|
|||
|
using Microsoft.AspNetCore.Http;
|
|||
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
|
|||
|
namespace MsLdap.Controllers
|
|||
|
{
|
|||
|
[Route("[controller]")]
|
|||
|
[ApiController]
|
|||
|
public class LdapController : ControllerBase
|
|||
|
{
|
|||
|
[HttpGet("users/by-id/{userID}")]
|
|||
|
public IActionResult GetUserById(string userID)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
UserInfo userInfo = LDAP.GetUserInfo(document: userID);
|
|||
|
|
|||
|
|
|||
|
return Ok(userInfo);
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
return BadRequest(ex.Message);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
[HttpGet("users/by-username/{username}")]
|
|||
|
public IActionResult GetUserByUsername(string username)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
UserInfo userInfo = LDAP.GetUserInfo(username: username);
|
|||
|
|
|||
|
|
|||
|
return Ok(userInfo);
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
return BadRequest(ex.Message);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
[HttpGet("users/by-mail/{mail}")]
|
|||
|
public IActionResult GetUserByMail(string mail)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
UserInfo userInfo = LDAP.GetUserInfo(email: mail);
|
|||
|
|
|||
|
|
|||
|
return Ok(userInfo);
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
return BadRequest(ex.Message);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
}
|