0
這是我的場景:我有一個正在處理的SharePoint網站,它位於一個服務器場中。在此網站中,我創建了一個HttpHandler,它使用位於不同服務器上的SharePoint搜索Web服務。這樣看起來是這樣的:當從HttpHandler調用時,SharePoint搜索Web服務錯誤(NTLM)
- SharePoint服務器A,在那裏我的地盤住
- 有服務引用到SharePoint搜索Web服務的服務器B上
- 具有使用該服務引用HTTP處理程序調用搜索服務
- SharePoint服務器B,其中搜索服務生活
我的代碼如下所示:
BasicHttpBinding binding = new BasicHttpBinding();
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
QueryServiceSoapClient _queryService = new QueryServiceSoapClient(binding, new EndpointAddress("http://easearch.ea.com/_vti_bin/search.asmx"));
_queryService.ClientCredentials.Windows.AllowNtlm = true;
_queryService.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
_queryService.ClientCredentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
//_queryService.ClientCredentials.Windows.ClientCredential = new NetworkCredential("MyUsername", "MyPassword", "MyDomain"); //This is the only way it seems to work
//NetworkCredential userCredential = CredentialCache.DefaultCredentials.GetCredential(_queryService.Endpoint.ListenUri, "NTLM");
//_queryService.ClientCredentials.Windows.ClientCredential = userCredential;
string status = _queryService.Status();
如果我使用從控制檯應用程序的代碼在我的dev的盒子,它按預期工作。但是,當我試圖從我的HTTP處理程序使用相同的代碼,它提供了錯誤
的HTTP請求是未經授權 客戶端身份驗證方案「NTLM」。 從服務器收到的認證標頭 是'NTLM'。
我已經嘗試了上面的代碼的數量不同的組合,並從我的HttpHandler唯一的作品是當我直接提供我的憑據。有人有主意嗎?
謝謝。
謝謝。我還使用了另一篇文章,http://stackoverflow.com/questions/262442/sharepoint-2007-ntlm-issue-with-asp-net-web-app-hosted-on-sharepoint-server/263226#263226,同樣的信息,以及另外幾個使用搜索網絡服務的選項。對我而言,不幸的是,在我的組織中,似乎Kerberos沒有得到很好的支持,所以我可能無法使用它。我也被告知在其他帖子中建議的DisableLoopbackCheck也不能解決我的問題。看起來我必須找到另一種方式去做我所需要的。不過謝謝。 – TehOne 2010-08-17 17:47:40