I am doing a POC in ASP.Net for IdP Initiated SSO.
I get logged in successfully with my AD credentials on ADFS login page.
But, on my assertion page, how can I get the SAML response and validate the the user?
I can see the response using developer tool but how can I get it using c#?
What I have tried:
I tried printing the values from SAMLResponse querystring parameter (I found this somewhere after googling. So not sure about how it actually works).
ClaimsPrincipal claimsPrincipal = System.Threading.Thread.CurrentPrincipal as ClaimsPrincipal;
Response.Write("Is user Authenticated = " + claimsPrincipal.Identity.IsAuthenticated.ToString()); I get this as : False
Response.Write(" Current Principal = " + System.Threading.Thread.CurrentPrincipal.ToString());
I get this as : System.Security.Principal.GenericPrincipal
string rawSamlData = Request["SAMLResponse"];
Response.Write("Raw data \n");
rawSamlData = HttpUtility.UrlDecode(rawSamlData);
Response.Write("after url decode \n");
byte samlData = Convert.FromBase64String(rawSamlData);
Response.Write("after base 64 \n");
string samlAssertion = Encoding.UTF8.GetString(samlData);
Response.Write("saml assertion \n");
All I get is some encrypted string. How can I decode it to SAML response and authenticate the user?