2

我正在尝试从 asp.net 应用程序调用 GetListItems。

System.Net.NetworkCredential userDefined = new System.Net.NetworkCredential("username","password","domain");
XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
XmlNode ndViewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
XmlNode ndQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");
ndQueryOptions.InnerXml = "";
ndViewFields.InnerXml = "";

WebReference.Lists lists = new WebReference.Lists();

lists.Credentials = userDefined;
XmlNode responseNode = lists.GetListItems("My List Name", null, ndQuery, ndViewFields, null, ndQueryOptions, null);

我收到一个错误:

the request failed with http status 401 unauthorized

我搜索了 SO 并尝试了我发现的内容:

WebReference.UseDefaultCredentials = true;

WebReference.Credentials = System.Net.CredentialCache.DefaultCredentials;

<identity impersonate="true"  userName="mydomain\username" password="password" />

我尝试过的所有操作都会收到相同的错误消息。有人知道我可能会错过什么吗?

4

1 回答 1

0

如果您的共享点使用浏览器身份验证,则需要预身份验证

svc.PreAuthenticate = true;
svc.Credentials = new System.Net.NetworkCredential(username, password);

http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/ac38e0da-c828-48b8-aa3f-fb22f30ce581

如果它的形式是 auth,或者 NTLM 以外的任何东西,那么会有更多的混乱 - 虽然到目前为止,我总是用 403 回应

于 2013-05-15T03:24:17.997 回答