Search code examples
c#ws-federation

wsFederation and passiveRedirectEnabled to false


I need your help concerning the following scenario :

I have a webapp, I configured it to be redirected to another website for getting the token.

This works very well, I made a page inspired from the EmbeddedSTS sample where we can select a user from a dropdown.

Now I need to change it for another environment, The requirements is that the user came to this page, need to accept a kind of disclaimer, then afterwards I need to authenticate this user against ADFS.

On the Identity site, I put "passiveRedirectEnabled" to false otherwhise the user will be automatically redirect to ADFS without having to confirm the disclaimer.

Now I'm blocked, I can t find a code that makes the redirection to ADFS working after.

I tried something like this :

FederatedAuthentication.WSFederationAuthenticationModule.RedirectToIdentityProvider(...);

But no redirection happens and since I'm on MVC site, I need to return a page ? I dont know how to use this method ?

Thanks in advance,


Solution

  • You can create the SignIn Url manually with the SignInRequestMessage Class.

    var signInRequestMessage = new SignInRequestMessage(new Uri("https://AdfsUrl"), "yourRealm", "https://yourRedirectUrl");
    var redirectUrl = signInRequestMessage.WriteQueryString();
    return RedirectTo(redirectUrl);
    

    https://msdn.microsoft.com/en-us/library/system.identitymodel.services.signinrequestmessage(v=vs.110).aspx