gpt4 book ai didi

c# - Sharepoint 通过网络服务访问 "User Information List"

转载 作者:太空狗 更新时间:2023-10-30 01:12:05 26 4
gpt4 key购买 nike

我正在尝试获取“用户信息列表”的内容。此列表只能作为管理员用户访问。我有一个以管理员用户身份登录然后执行以下操作的方法:

var xmlDoc = new XmlDocument();
var query = xmlDoc.CreateElement("Query");
query.InnerXml = "<Where><Eq><FieldRef Name='ContentType' /><Value Type='Choice'>Person</Value></Eq></Where>";
XmlElement viewFields = xmlDoc.CreateElement("ViewFields");
viewFields.InnerXml = "<FieldRef Name='Title' />";
XmlElement queryOptions = xmlDoc.CreateElement("QueryOptions");
var items = ws.GetListItems("User Information List", "", query, viewFields, string.Empty, queryOptions, "8A391AE3-2783-489B-8BDF-D2AE971D73CD");

我的列表名称是正确的,我通过 SharePoint Explorer 从下面获得的 GUID 也是正确的

<List DocTemplateUrl="" DefaultViewUrl="/_catalogs/users/detail.aspx" MobileDefaultViewUrl="" ID="{8A391AE3-2783-489B-8BDF-D2AE971D73CD}" Title="User Information List" Description="All people." ImageUrl="/_layouts/images/users.gif" Name="{8A391AE3-2783-489B-8BDF-D2AE971D73CD}" BaseType="0" FeatureId="" ServerTemplate="112" Created="20080430 02:48:38" Modified="20090819 08:31:52" LastDeleted="20090604 12:32:50" Version="141" Direction="none" ThumbnailSize="" WebImageWidth="" WebImageHeight="" Flags="41971988" ItemCount="46" AnonymousPermMask="0" RootFolder="/_catalogs/users" ReadSecurity="1" WriteSecurity="1" Author="1" EventSinkAssembly="" EventSinkClass="" EventSinkData="" EmailInsertsFolder="" EmailAlias="" WebFullUrl="/" WebId="767c0b20-058d-4b53-8362-81e005bf5098" SendToLocation="" ScopeId="64857900-37cf-431c-be07-5528d1ae46af" MajorVersionLimit="0" MajorWithMinorVersionsLimit="0" WorkFlowId="" HasUniqueScopes="False" AllowDeletion="False" AllowMultiResponses="False" EnableAttachments="True" EnableModeration="False" EnableVersioning="False" Hidden="True" MultipleDataList="False" Ordered="False" ShowUser="True" EnableMinorVersion="False" RequireCheckout="False" />

我收到以下错误:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.</faultstring>
<detail>
<errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">The system cannot find the file specified. (Exception from HRESULT: 0x80070002)</errorstring>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>

你知道我为什么会收到这个错误吗?

更新

线

var items = ws.GetListItems("User Information List", "", query, viewFields, string.

在 C# 代码中抛出异常。抛出的异常是:

Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.

帮助不大...

更新 2

我在网上找到了这个 http://www.aidangarnish.net/blog/post/2008/04/Retrieving-items-from-a-MOSS-2007-list-using-web-services.aspx并将我的代码更改为:

var node = ws.GetListItems("User Information List", String.Empty, null, null, String.Empty, null, null);

我现在得到结果了!仍然不确定我的初始查询有什么问题,所以问题仍然存在......

最佳答案

如果您再次遇到“系统找不到指定的文件。(异常来自 HRESULT:0x80070002)”,只需尝试将最后一个参数“webId”设置为 null。

看微软的web服务规范说:

webID: Optional. A string containing the GUID of the parent Web site for the list surrounded by curly braces ({}). Setting this parameter to null means the Web site specified by the URL property of the service will be used, and if the URL property of the service is not specified, the root Web site will be used.

来源:http://msdn.microsoft.com/en-us/library/lists.lists.getlistitems(v=office.12).aspx

关于c# - Sharepoint 通过网络服务访问 "User Information List",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1305324/

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