I would like to have the PrincipalContext ValidateCredentials method made async.
public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
{
using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, "gob.uk"))
{
if (pc.ValidateCredentials(model.Email, model.Password))
{
returnUrl = "/Home/index";
return RedirectToLocal(returnUrl);
}
else
{
ModelState.AddModelError("", "Invalid login attempt.");
return View(model);
}
}
}
As you can see I am trying to use Active Directory to authenticate users, but it seems that pc.ValidateCreadentials is a sync method. How can I make it async?