My goal is to setup a SSO-like environment (not fully support SSO), with below behaviour:
- User logon in System_A (java)
- When user click on a specify link, System_A will generate a security token, timestamp, and redirect the user to System_B (SharePoint with FBA) http://system_b/_forms/default.aspx?u=UserName&tkn=[SECURITY_TOKEN + TIMESTAMP with some encryption....]
- System_B implemented custom membership provider, it makes some webservice call to System_A to validate the user session in the ValidateUser(string username, string password) method. Refer: http://blog.sharedove.com/adisjugo/index.php/2011/01/05/writing-a-custom-membership-provider-and-using-it-for-fba-forms-based-authentication-in-sharepoint-2010-from-the-scratch/
Remarks
User can ONLY visit System_B by the link generate after logon on System_A, so it's not a real SSO situation.
When user logout from System_B, doesn't need to logout System_A vice versa.
Everything is OK, except user unable to logout on SharePoint. here are the findings: 1. If I use normal form login flow (i.e. /_forms/default.aspx, and enter username, password) , it has no problem in logging-out.
In normal form flow, it will write a cookie name FedAUTH=xxxxxxxxxxx
If I use auto-login link, (i.e. /_forms/default.aspx?u=UserName&tkn=[SECURITY_TOKEN + TIMESTAMP with some encryption....]), it will write a cookie name with .ASPXAUTH=xxxxxxxxxx
I customized the /_forms/default.aspx as below:
protected override void OnLoad(EventArgs e) { base.OnLoad(e); SetLoginInfo(); } private void SetLoginInfo() { if (!IsPostBack) { string u = Request.Params["u"]; string tkn = Request.Params["tkn"]; if (!String.IsNullOrEmpty(u) && !String.IsNullOrEmpty(tkn)) { MembershipProvider mp = Membership.Providers["My Membership Provider"]; if (mp.ValidateUser(u, tkn)) { string spname = GetSPEncodeClaimName(u); FormsAuthentication.SetAuthCookie(spname, false); Page.Response.Redirect("/", false); } } } } protected string GetSPEncodeClaimName(string username) { string encodeName = null; SPClaimProviderManager mgr = SPClaimProviderManager.Local; if (mgr != null) { SPClaim claim = new SPClaim(SPClaimTypes.UserLogonName, username, "http://www.w3.org/2001/XMLSchema#string", SPOriginalIssuers.Format(SPOriginalIssuerType.Forms, "My Membership Provider")); encodeName = mgr.EncodeClaim(claim); encodeName = encodeName.Substring(encodeName.IndexOf(':') + 1); } return encodeName; } The problem seem come from the cookie's name, am I correct? if so, how to change the cookie name? Is there any other better way to implement this logic? Thanks a lot.