c# - 作为当前用户使用 Web 服务添加列表项

标签 c# asp.net web-services sharepoint

我可以使用 asp.net web 应用程序成功地将列表项添加到列表中。但是,“创建者”字段包含服务器的名称,而不是访问该站点的当前用户。

服务器 A 托管我的 asp.net 网络应用程序。用户访问该站点,单击一个按钮,该按钮将项目添加到托管 SharePoint 站点的服务器 B。我无权访问服务器 B,因此无法使用 Web 服务。

这是我当前的代码:

webreference.Lists myList = new webreference.Lists();  
//have also tried DefaultNetworkCredentials   
myList.Credentials = System.Net.CredentialCache.DefaultCredentials;    
myList.Url = "http://site/_vti_bin/lists.asmx";    
XmlDocument doc = new XmlDocument();    
XmlElement batch = doc.CreateElement("Batch");   
batch.SetAttribute("OnError", "Continue");   
batch.InnerXml = "<Method ID='1' Cmd='New'>" +   
"<Field Name='Title'>Test</Field>" +    
"</Method>";    
myList.UpdateListItems("{LIST GUID}", batch);

最佳答案

我相信,为了在层之间传递这样的凭据,您需要使用 Kerberos 进行委托(delegate)。否则 DefaultCredentials 将为空。这被称为 NTML“双跃点”问题。看this post on MSDN Forums where the fellow suggests changing NTAuthenticationProviders .

关于c# - 作为当前用户使用 Web 服务添加列表项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8185121/

相关文章:

c# - ASP.Net Core Web API 中的返回文件

c# - 添加具有优先级的TFS任务,分配给使用c#

asp.net - 最新的 IIS 版本中不存在机器 key 生成功能

ASP.NET 网站 DLL : Debug vs. 发布版本

asp.net - 具有物理根的应用程序无法使用命令行 'dotnet .\AppName.dll' 启动进程,ErrorCode = '0x80004005 : 80008083

java - 调用 url 并使用 HttpGet 发送 JSONObject

c# - 带有 NUnit 的 Microsoft PEX

c# - 当我想双击时如何避免单击?

c# - 基于查询参数的 WCF REST 服务 url 路由

java - wsimport 两个声明导致冲突