Sharepoint访问“用户信息列表”通过网络服务

发布于 2024-08-02 13:57:43 字数 3627 浏览 2 评论 0原文

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

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");

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

<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/Retriving -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);

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

I am trying to get the contents of "User Information List". This list can only be acessed as an admin user. I have a method that logs in as the admin user and then does the following:

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");

My list Name is Correct and so is the GUID I got htat from below via SharePoint Explorer

<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" />

I am being returned the following error:

<?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>

Do you know why I am getting this error?

Update

The line

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

Is throwing an exception in the C# code. The exception being thrown is:

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

Not a lot of help...

Update 2

I found this on the web http://www.aidangarnish.net/blog/post/2008/04/Retrieving-items-from-a-MOSS-2007-list-using-web-services.aspx and changed my code to:

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

I am now getting results! Still not sure what is wrong with my initial query so the question stands...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

殤城〤 2024-08-09 13:57:43

如果您再次遇到“系统找不到指定的文件。(Exception from HRESULT: 0x80070002)”问题,只需尝试将最后一个参数“webId”设置为空即可。

看看微软的网络服务规范:

webID:可选。包含父网站 GUID 的字符串
对于用大括号 ({}) 括起来的列表。设置该参数
为 null 表示由 URL 属性指定的网站
将使用服务,并且如果服务的 URL 属性不是
指定后,将使用根网站。

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

If you encountered the problem "The system cannot find the file specified. (Exception from HRESULT: 0x80070002)" again, just try to set the last parameter "webId" to null.

Look at specification of the web service by Microsoft saying:

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.

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

冰之心 2024-08-09 13:57:43

,那么我运气更好,包括不必以管理员身份登录

  • 我不确定这会回答您的问题,但是,如果您使用以下方式访问用户信息表: “UserInfo”

而不是:

  • “用户信息” 列表”

它在此处的文档中列出:
http://msdn.microsoft.com/en-us/库/lists.lists.getlist.aspx

listName
包含列表标题或 GUID 的字符串。查询 UserInfo 表时,字符串包含“UserInfo”。

也许可以尝试一下。

I'm not sure this will answer your question, but, I have had a lot more luck, including not having to be logged on as an administrator, if you access the User Information Table using:

  • "UserInfo"

Instead of:

  • "User Information List"

Its listed in the documentation here:
http://msdn.microsoft.com/en-us/library/lists.lists.getlist.aspx

listName
A string that contains either the title or the GUID for the list. When querying the UserInfo table, the string contains "UserInfo".

Perhaps give that a shot.

巴黎夜雨 2024-08-09 13:57:43
var node = ws.GetListItems("User Information List", String.Empty, null, null, String.Empty, null, null);

经过反复试验,似乎工作得很好。

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

Seems to work fine from trial and error.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文