Authenticating against AD FS from a .Net 4.5 Console App

*爱你&永不变心* 提交于 2019-12-09 06:51:05

问题


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


回答1:


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).



来源:https://stackoverflow.com/questions/14521589/authenticating-against-ad-fs-from-a-net-4-5-console-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!