function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AthaduAthadu 

IdP initiated SSO with SalesForce - Login History shows logged in with SSO but user is taken to the login page

Hi

I am trying to implement an IdP initiated SSO with my DEV edition of Salesforce - basically login to my SF from a local web app.

I am generating the SAML2.0 using .NET from an ASP.NET MVC app and using an HTTP POST to post the saml token. 

The SAML2.0 assertion validates successfully in the Validator tool.

I have my SF org link "https://xxxxxxx-dev-ed.my.salesforce.com?so=00DU0000000Y2Vx" as the receipient, my dev environment "http://localhost:25364/" as the issuer, "https://saml.salesforce.com" as the Allowed Audiences, my SF user account in the SAML subject.

After the HTTP POST, the Login History shows that the IdP SSO login attempt is successful.

But, after the login the user is taken to my login page in Salesforce.  I am expecting it to take me to my SF Home page.

Following are the screenshots showing relevant info including ASP.NET MVC code on how I am doing the HTTP POST from a Controller Action method.

Greatly appreciate any pointers on what I could be missing.

Thank you

SAML 2.0 Validator Results

Single Sign On Settings

SSO Login History showing successful login attempts

SSO Login taking me to the login screen - expecting it to take me to the Home Page instead

Here is how I am doing a HTTP Post from an ASP.NET MVC Controller Action Method.
var xml = <.............SAML Response XML here ................>
            //  the RelayState parameter to control where users get redirected after a successful login
            var postData = String.Format("SAMLResponse={0}&RelayState={1}",
                        System.Web.HttpUtility.UrlEncode(
                        xml),
                        System.Web.HttpUtility.UrlEncode("https://yk-dev-ed.my.salesforce.com/home/home.jsp"));

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://yk-dev-ed.my.salesforce.com?so=00DU0000000Y2Vr");

            // set post headers
            request.Method = WebRequestMethods.Http.Post;
            //request.KeepAlive = true;
            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = postData.Length;

            // write the data to the request stream         
            //StreamWriter writer = new StreamWriter(request.GetRequestStream());
            //writer.Write(postData);

            // iirc this actually triggers the post
            //HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))
            {
                writer.Write(postData);
            }

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            using (StreamReader reader = new StreamReader(response.GetResponseStream()))
            {
                var txt = reader.ReadToEnd();
                Response.Write(txt);
            }

 
sheenam  jaggasheenam jagga
Did you get any solution as I am facing the same issue.