So far, my best idea has been to check the username in the users cookie (if it exists) or from the usual login form when the cookie does not exist. Using this information, I can determine if it should be sent to IdP or not. In case you need to send it to IdP, I can simply create the request URL and redirect it.
WSFederationAuthenticationModule instance = FederatedAuthentication.WSFederationAuthenticationModule; SignInRequestMessage request = instance.CreateSignInRequest(Guid.NewGuid().ToString(), instance.Realm, true); request.AuthenticationType = "urn:federation:authentication:windows"; Response.Redirect(request.WriteQueryString());
Of course, I can configure this request with the corresponding .HomeRealm or .AuthenticationType value to skip the HRD process, and then after that they will be sent back to the application with authentication and with proper identification.
One of the reasons that this is not an ideal answer for me is that if the user has never registered before or turned off cookies, and depending on the federation, they have the opportunity to log in twice. That is, once in the application login form and once in the ADFS form. That's why I was hoping you could send the request programmatically in some way instead of redirecting. That way, I could presumably send the username and password that were already collected by the application, without having to collect them again in ADFS.
For this reason, I will not mark this as an answer. I would like to hold out better.
source share