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

查看:21
本文介绍了从 .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天全站免登陆