问题描述
到目前为止,我发现了两种解决方案来从ClaimsIdentity获取WindowsIdentity对象。
首先我提取用户主体名称(upn)。
So far I found out two solutions to get a WindowsIdentity object from a ClaimsIdentity.First I extract the user principal name (upn).
ClaimsIdentity ci = (ClaimsIdentity) Thread.CurrentPrincipal.Identity;
string upn = null;
foreach (Claim c in ci.Claims)
{
if (c.ClaimType == ClaimTypes.Upn)
{
upn = c.Value;
break;
}
}
-
用upn调用WindowsIdentity的构造函数:
Just call the constructor of WindowsIdentity with the upn:
WindowsIdentity winId = new WindowsIdentity(upn);
WindowsIdentity winId = new WindowsIdentity(upn);
使用对Windows令牌服务(c2WTS)的声明:
Use Claims to Windows Token Service (c2WTS):
WindowsIdentity winId = S4UClient.UpnLogon(upn);
WindowsIdentity winId = S4UClient.UpnLogon(upn);
解决方案1对我来说似乎是更简单,更轻松的解决方案,但后来我不明白c2WTS的目的吗?
Solution 1 seems for me the simpler and easier solution, but then i don't understand the purpose of the c2WTS?
有什么建议吗?
tnx!
推荐答案
-
WindowsIdentity winId = S4UClient.UpnLogon(upn);
WindowsIdentity winId = S4UClient.UpnLogon(upn);
由Excel Services和PerformancePoint服务使用。
Used by Excel Services and PerformancePoint services.
使用后将其缓存。还有其他针对它的检查。
Its cached once used. Has some other checks against it as well.
这篇关于从ClaimsIdentity检索WindowsIdentity的最佳方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!