gpt4 book ai didi

c# - 使用 SharePoint Web 服务进行身份验证

转载 作者:太空宇宙 更新时间:2023-11-03 16:17:00 25 4
gpt4 key购买 nike

我正在尝试从 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" />

我尝试过的所有方法都得到了相同的错误消息。有人知道我可能遗漏了什么吗?

最佳答案

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

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 响应

关于c# - 使用 SharePoint Web 服务进行身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15525102/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com