[英]Impersonate User in SharePoint 2010 web part to call WCF service
我有一個Web部件,我試圖在其中調用WCF服務作為當前登錄用戶。 在Visual Studio 2013中調試時,Web部件在本地工作-調用外部WCF服務。 我已經為WCF服務以及SharePoint網站配置了Kerberos,而這樣做的費用都是正確的。 我可以從另一個啟用了Kerberos的Web應用程序以及從控制台應用程序正確調用WCF服務。
現在,我想將此滾動到SharePoint服務器場。 但是,在將解決方案添加到服務器場並激活共享點網站上的功能后,嘗試將Web部件添加到頁面時出現錯誤。 該錯誤出現在顯示“呼叫者未通過服務驗證”的框中。 錯誤來自實際方法調用。
我的Web部件代碼是這樣的:
WorksiteService.iWorksiteServiceClient wss = new WorksiteService.iWorksiteServiceClient("WSHttpBinding_iWorksiteService");
wss.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
wss.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;
WorkSiteDocument[] wd = wss.GetDocumentsByAlias2("test");
共享點站點中的web.config具有此端點:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_iWorksiteService" />
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://myservicerd.xyz.com/WorkSiteService.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_iWorksiteService" contract="WorksiteService.iWorksiteService" name="WSHttpBinding_iWorksiteService">
<identity>
<servicePrincipalName value="myservicerd.xyz.com" />
</identity>
</endpoint>
</client>
</system.serviceModel>
關於我為什么收到該錯誤的任何想法? 我假設由於某種原因我沒有獲得當前用戶的憑據。共享點服務器或wcf服務器的事件或共享點日志中沒有任何內容。 關於如何解決此問題的任何想法?感謝您提供的任何幫助。
我不是Sharepoint專家,但從Kerberos的角度來看,我建議按照Marek的建議檢查Active Directory中的委托設置。
在像這樣的雙跳場景中,必須允許中間的“人”扮演客戶的身份。
問題仍然是中間的“人”是誰,這取決於IIS配置。 如果將IIS配置為用於內核模式身份驗證,則在安裝服務器IIS的情況下,中間身份可能是計算機帳戶。
否則,我將假定需要委派權限的身份應該是Web部件在其中運行的應用程序池的身份。
如果確定了身份,請轉到相應的Active Directory帳戶(“代理”選項卡),然后選擇“信任帳戶可進行委派”。
也許這篇博客文章可以對此有所啟發 : http : //tekaris.com/blog/2013/04/05/http-400-bad-request-kerberos-authentication-with-iis-2/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.