声称对Windows令牌服务模拟令牌

时间:2012-01-12 15:40:45

标签: sharepoint impersonation claims c2wts

我有一个基于声明的SharePoint 2010网站,我需要呼叫后端非声明感知系统(K2 blackpearl)。

为了达到这个目的,我试图使用Windows令牌服务声明模仿用户here

现在使用用户UPN调用c2wts以使用以下代码转换为声明:

WindowsIdentity windowsIdentity = null;
SPSecurity.RunWithElevatedPrivileges(
delegate()
{
windowsIdentity = S4UClient.UpnLogon("user@domain.com");
});

现在我冒充windowsIdentity.ImpersonationLevel是识别而非模仿

using (WindowsImpersonationContext c = windowsIdentity.Impersonate())
{
Debug.WriteLine(WindowsIdentity.GetCurrent().ImpersonationLevel); // returns Identification
ConnectToK2();
c.Undo();
} 

我认为这是导致问题的原因,因为当尝试使用令牌失败时调用服务时。上面提到的文章讨论了如何获取模拟令牌,但我无法做到这一点。

有谁知道我可能做错了什么?

由于

1 个答案:

答案 0 :(得分:0)

要使模拟级别等于模拟,请将web.config中的模拟设置为false:

    <identity impersonate="false" />

另外,请尝试不要在“SPSecurity.RunWithElevatedPrivileges”中执行模拟,因为这样您将进行两次模拟 - 首先是作为Web应用程序池帐户(这是RunWithElevatedPriviliges正在引起的),然后使用来自c2wts的令牌进行手动模拟。 / p>

相关问题