我已經使用LDAP在ASP.NET MVC 5中實現了Active Directory身份驗證。我想知道如何獲得用戶的如何從Active Directory獲取用戶的密碼到期日期?
- 帳戶鎖定(布爾)
- 密碼過期(布爾)
- 密碼到期日期(日期時間)
這是我當前的代碼:
using System.Web.Mvc;
using System.Web.Security;
using MvcApplication.Models;
[HttpPost]
public ActionResult Login(LoginModel model, string returnUrl)
{
if (!this.ModelState.IsValid)
{
return this.View(model);
}
if (Membership.ValidateUser(model.UserName, model.Password))
{
FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
if (this.Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
&& !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
{
return this.Redirect(returnUrl);
}
return this.RedirectToAction("Index", "Home");
}
this.ModelState.AddModelError(string.Empty, "The user name or password provided is incorrect.");
return this.View(model);
}
public ActionResult LogOff()
{
FormsAuthentication.SignOut();
return this.RedirectToAction("Index", "Home");
}
我希望儘可能地使用System.Web.Security。通過我可以檢索AccountLocked。現在我需要知道如何將我的LDAP Activedirectory實例化爲對象,以便我可以獲取其對象屬性。任何人都知道如何實現? – user1166085