【发布时间】:2017-06-24 11:09:29
【问题描述】:
我有一个在 .Net Framework 4.5 中工作的代码,但我需要在 .Net 3.5 中的等效代码。我的问题是,我几乎所有的谷歌搜索结果要么是使用新 WIF 的解决方案,要么是关于旧 WIF 3.5 的一般信息。
代码如下所示:
using Microsoft.IdentityModel.Clients.ActiveDirectory;
namespace x
{
class y
{
public string GetAuthenticationHeader(Ax7Config config)
{
var user = new UserCredential(config.username, config.password);
return new AuthenticationContext(config.tenant)
.AcquireToken(config.resource, config.clientAppId, user)
.CreateAuthorizationHeader();
}
}
}
PS: 生成的 dll 会作为插件导入在 3.5 .net 框架上运行的应用程序中,并且无法重新编译为最新的框架。所以这行不通。
附:
对于它的价值,我知道.CreateAuthorizationHeader() 只会返回"Bearer " + AccessToken。所以这不是问题。获取AccessToken是。
【问题讨论】:
标签: c# security wif bearer-token