我遇到此錯誤:成員資格憑證驗證失敗。當我嘗試使用基於表單的身份驗證在ASP.NET應用程序中使用Active Directory用戶登錄時。成員資格憑證驗證失敗
我有一個複雜的設置,如下圖所示:
我使用的是Active Directory輕型目錄服務(AD LDS),又名亞當會員庫。 我使用代理用戶將其綁定到Active Directory並完成adamsync。 我爲AD LDS配置了SSL證書。 使用LDP.exe連接到AD LDS時,我可以連接/綁定AD LDS用戶或AD用戶,因此代理服務器正常。 我的ASP.NET應用程序與AD LDS對話,我能夠使用基於表單的身份驗證成功地與AD LDS用戶進行登錄。
但我無法登錄與我的AD用戶與ASP.NET應用程序,我錯過了什麼?
繼承人從我的web.config我的提供者部分:
<add name="MyADConnectionString"
connectionString="LDAP://localhost/OU=Users,DC=PreuveConcept,DC=local" />
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
<membership defaultProvider="AspNetActiveDirectoryMembershipProvider">
<providers>
<clear/>
<add name="AspNetActiveDirectoryMembershipProvider"
type="System.Web.Security.ActiveDirectoryMembershipProvider"
connectionStringName="MyADConnectionString"
connectionProtection="Secure"
enableSearchMethods="true"/>
</providers>
</membership>
我的繼承人登錄操作(默認MVC AcountControler):
[HttpPost]
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
if (ModelState.IsValid)
{
if (Membership.ValidateUser(model.UserName, model.Password))
{
FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
&& !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Index", "Home");
}
}
else
{
ModelState.AddModelError("", "The user name or password provided is incorrect.");
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
你可以發佈你的代碼..。你有沒有考慮過看PrincipalContext ..?你是如何傳遞DC = CN =等...?在網絡配置或ASP.NET類 – MethodMan
也請看看這裏的網站點擊ContextOptions鏈接它說選項http://msdn.microsoft.com/en-us/library/bb300969.aspx | http://msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement.contextoptions.aspx PrincipalContext可能是您更好的選擇 – MethodMan
我沒有檢查PrincipalContext,因爲我使用ActiveDirectoryMembershipProvider,我假設它能夠執行此類連接。 – Groumy