I'm in the process of getting my head round using AD FS to authenticate a user in a .NET 4.5 app. I can't find any examples of requesting/receiving the token from a console app and converting that token into a ClaimsPrinciple. The only examples I can find are WCF configuration based and I would really like to see the actual code that can do this in it's simplest form.
I've installed AD FS and think I've got it configured ready to receive requests. I've created a relying party, given it a key and assigned a couple of claims to it.
Can anyone point me in the right direction or what I need to do now in my console app to send authentication requests to it?
Thanks
The easiest way is to use the WSTrustChannelFactory from .NET 4.5.
See the RequestSecurityToken method here: http://leastprivilege.com/2012/11/16/wcf-and-identity-in-net-4-5-external-authentication-with-ws-trust/
After you have the token you run it through the corresponding token handler to turn it into a ClaimsPrincipal.
I have helper methods and bindings in my library on github: https://github.com/thinktecture/Thinktecture.IdentityModel.45
(look for the WCF folder, WSTrustClient and the Extensions folder).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With