[英]Single sign on inside asp.net mvc web application
我的內部網絡上有兩個域: -
這兩個區可與對方溝通,但他們不信任對方。
所以目前我已經在IIS上的domainA中部署了我的asp.net MVC Web應用程序,但是我需要在DomainB Active目錄下的用戶能夠使用他們的domainB AD憑據登錄到asp.net mvc。 我對我的asp.net mvc中的Windows身份驗證和表單身份驗證都持開放態度。
但是來自客戶端的唯一要求是他們希望用戶從domainB上的機器訪問asp.net mvc內部網應用程序,以便能夠在沒有登錄頁面的情況下進入系統; 他們可以: -
那么,任何人都可以建議我可以遵循的方法,實現這一目標嗎? 謝謝
編輯我已閱讀以下文章http://msdn.microsoft.com/en-us/library/ff650307.aspx ,關於如何從多個域驗證asp.net mvc用戶,所以在我的asp.net mvc我做了下列 :-
我在web.config中添加了以下內容: -
<system.web>
<membership>
<providers>
<add name="TestDomain1ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider" connectionStringName="TestDomain1ConnectionString" connectionUsername="ad-domainA.intra\it360ad.user" connectionPassword="$$$$$" />
</providers>
</membership>
&
<add name="TestDomain1ConnectionString" connectionString="LDAP://ad-domainA.intra/CN=Users,DC=ad-domainA,DC=intra" />
我添加了以下Account.controller: -
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Login(LoginModel model, string returnUrl)
{
MembershipProvider domainProvider;
domainProvider = Membership.Providers["TestDomain1ADMembershipProvider"];
// Validate the user with the membership system.
if (domainProvider.ValidateUser(model.UserName, model.Password))
{
// If there is a RequestUrl query string attribute, the user has
// been redirected to the login page by forms authentication after
// requesting another page while not authenticated.
if (Request.QueryString["ReturnUrl"] != null)
{
// RedirectFromLoginPage sets the authorization cookie and then
// redirects to the page the user originally requested.
// Set second parameter to false so cookie is not persistent
// across sessions.
FormsAuthentication.RedirectFromLoginPage(
model.UserName, false);
}
else
{
// If there is no RequestUrl query string attribute, just set
// the authentication cookie. Provide navigation on the login page
// to pages that require authentication, or user can use browser
// to navigate to protected pages.
// Set second parameter to false so cookie is not persistent
// across sessions.
FormsAuthentication.SetAuthCookie(model.UserName, false);
}
}
else
{
// Response.Write("Invalid UserID and Password");
ModelState.AddModelError("", "The user name or password provided is incorrect.");
return View(model);
}
////////////
//if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
//{
return RedirectToLocal(returnUrl);
//}
// If we got this far, something failed, redisplay form
}
但是目前當用戶嘗試登錄時,他將始終獲得以下消息
•The user name or password provided is incorrect.
如果我的代碼是正確的,你能建議嗎?
您必須在加入DomainB的服務器上部署SSO解決方案,如Active Directory聯合身份驗證服務。
然后在應用程序(例如,WS-Federation Passive Requestor)中實現身份驗證,該身份驗證針對的是針對DomainA的SSO解決方案和標准Windows身份驗證。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.