2

我想让 PrincipalContext ValidateCredentials 方法异步。

     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);
            }
        }
  }

如您所见,我正在尝试使用 Active Directory 对用户进行身份验证,但似乎 pc.ValidateCreadentials 是一种同步方法。我怎样才能使它异步?

4

0 回答 0