2012-01-12 34 views
1

我有一個基於聲明的SharePoint 2010網站,我需要呼叫到後端非聲明感知系統(K2 blackpearl)。聲稱Windows令牌服務模仿令牌

因此,要實現這一目標,我嘗試使用聲明爲Windows令牌服務來模擬用戶描述here

現在使用用戶UPN使用下面的代碼轉換爲要求調用C2WTS時:

WindowsIdentity windowsIdentity = null; 
SPSecurity.RunWithElevatedPrivileges(
delegate() 
{ 
windowsIdentity = S4UClient.UpnLogon("[email protected]"); 
}); 

現在,當我模擬該windowsIdentity.ImpersonationLevel是標識,而非模仿

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

我認爲這是什麼導致問題,因爲當試圖使用它失敗的令牌調用服務時。上面提到的文章談到了獲取模擬的令牌,但我無法做到這一點。

有誰知道我可能做錯了什麼?

感謝

回答

0

爲了讓模擬級別等於模擬,模擬設置在你的web.config爲false:

<identity impersonate="false" /> 

也儘量不要因爲這樣一來你「SPSecurity.RunWithElevatedPrivileges」內執行模擬正在執行兩次模擬 - 首先作爲一個Web應用程序池帳戶(這是RunWithElevatedPriviliges造成的),然後使用c2wts中的令牌進行手動模擬。