通过.Net 4.5控制台应用程序针对AD FS进行身份验证 [英] Authenticating against AD FS from a .Net 4.5 Console App

查看:88
本文介绍了通过.Net 4.5控制台应用程序针对AD FS进行身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用AD FS来验证.NET 4.5应用中的用户身份。我找不到从控制台应用程序请求/接收令牌并将该令牌转换为ClaimsPrinciple的任何示例。我可以找到的唯一示例是基于WCF配置的,我真的很想看看可以以最简单的形式完成此操作的实际代码。

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.

我已经安装了AD FS并认为我已经将其配置为可以接收请求。我创建了一个依赖方,为其提供了密钥,并为其分配了一些要求。

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?

谢谢

推荐答案

最简单的方法是使用.NET 4.5中的WSTrustChannelFactory。

The easiest way is to use the WSTrustChannelFactory from .NET 4.5.

在此处查看RequestSecurityToken方法:
http://leastprivilege.com/2012/11/16/wcf-and-identity-in-net-4-5-external-authentication-with-ws -trust /

See the RequestSecurityToken method here: http://leastprivilege.com/2012/11/16/wcf-and-identity-in-net-4-5-external-authentication-with-ws-trust/

获得令牌后,通过相应的令牌处理程序将其运行以将其转换为ClaimsPrincipal。

After you have the token you run it through the corresponding token handler to turn it into a ClaimsPrincipal.

我在github上的库中有帮助方法和绑定:
https:// github .com / thinktecture / Thinktecture.IdentityModel.45

I have helper methods and bindings in my library on github: https://github.com/thinktecture/Thinktecture.IdentityModel.45

(查找WCF文件夹,WSTrustClient和Extensions文件夹)。

(look for the WCF folder, WSTrustClient and the Extensions folder).

这篇关于通过.Net 4.5控制台应用程序针对AD FS进行身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆