我可以使用 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/