WSS GetListItems Not Returning Folders without Inherited Permissions when Calling with GUID

我与影子孤独终老i 提交于 2020-01-06 16:33:27

问题


WSS 3.0 List Service

I am running GetListItems() on a Picture Library (name Pictures) using the follow CAML query:

<Query>
</Query>
<ViewFields>
  <FieldRef Name="EncodedAbsUrl"/>
  <FieldRef Name="Title"/>
  <FieldRef Name="ContentType"/>
</ViewFields>
<QueryOptions>
  <Folder>Pictures\Uploads</Folder>
  <ViewAttributes Scope="RecursiveAll"/>
</QueryOptions>

This query correctly returns all files and folders in the Uploads folder.

However, if I navigate to the Uploads folder and select Edit Permissions on the Uploads folder then select Actions > Edit Permissions and then click OK on the confirmation box this query no longer works.

I do not believe this is related to permissions, because I did not modify the permissions at all I just “cop[ied] permissions from parent, and then stop[ped] inheriting permissions,” by selecting Edit Permissions. In addition, I do not receive an error message when running this query, I just get an empty result set.

Other things I have tried:

  • Removing all tags in QueryOptions: This still does not return the Uploads folder or any file or folder under it
  • Adding permissions directly to the folder for my user account: This does not help
  • Searching for something with a similar problem or some sort of solution: No avail

Other information:

  • Calling this from C# Win Form App

Does anyone know how to fix or work around this? If more detail or clarification is necessary please let me know.

So after some more experimenting, a solution was found, though not well explained or documented. The problem was related to how the GetListItems function was being called, here is the code that was not working correctly:

System.Xml.XmlNode ndListView = listProxy.GetListAndView("Pictures", "");
string strListID = ndListView.ChildNodes[0].Attributes["Name"].Value;
XmlNode returnNode = listProxy.GetListItems(strListID, strViewID, queryNode, viewNode, _maxFolders, optionNode, null);

This was not working as expected for the situation explained above, however, it was working for every other folder and file. The solution was to send GetListItems the list name, "Pictures" instead of the list GUID, like so:

XmlNode returnNode = listProxy.GetListItems("Pictures", strViewID, queryNode, viewNode, _maxFolders, optionNode, null);

Update
Furthermore, MSDN documentation recommends the usage of GUID instead of the list name when using the Lists.GetListItem method:

listName: A string that contains either the display name or the GUID for the list. It is recommended that you use the GUID, which must be surrounded by curly braces ({}). When querying the UserInfo table, the string contains "UserInfo".

I do not know why this code works and the original does not. Although my problem has been solved, does anyone have a clue why my original code does not work (only for the situation explained above) and the modified code work?


回答1:


So after some more experimenting, a solution was found, though not well explained or documented. The problem was related to how the GetListItems function was being called, here is the code that was not working correctly:

System.Xml.XmlNode ndListView = listProxy.GetListAndView("Pictures", "");
string strListID = ndListView.ChildNodes[0].Attributes["Name"].Value;
XmlNode returnNode = listProxy.GetListItems(strListID, strViewID, queryNode, viewNode, _maxFolders, optionNode, null);

This was not working as expected for the situation explained above, however, it was working for every other folder and file. The solution was to send GetListItems the list name, "Pictures" instead of the list GUID, like so:

XmlNode returnNode = listProxy.GetListItems("Pictures", strViewID, queryNode, viewNode, _maxFolders, optionNode, null);


来源:https://stackoverflow.com/questions/1647242/wss-getlistitems-not-returning-folders-without-inherited-permissions-when-callin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!