使用“管理个人视图”以编程方式创建个人列表视图仅权限
在我目前正在进行的项目中,我必须为给定列表创建个人列表视图(SharePoint 2007)。这是我的代码(currList 是 SPList):
System.Collections.Specialized.StringCollection viewFields = currList.Views[BaseViewID].ViewFields.ToStringCollection();
SPView searchView = currList.Views.Add(SearchViewName, viewFields, query, 100, true, false, Microsoft.SharePoint.SPViewCollection.SPViewType.Html, true);
当用户有权将元素添加到列表时,一切工作正常。为用户创建视图,该用户对列表具有除添加项目之外的所有权限,会出现“访问被拒绝”错误。从 SharePoint 本身添加视图是可行的。
我在这里发现了同样的问题: http://us. Generation -nt.com/security-issue-while-creating-personal-view-programmatically-help-86373652.html 所以这个问题并不新鲜。
//编辑: 如果我创建个人视图(将项目添加到列表并管理个人视图权限),我稍后可以仅使用管理个人视图权限修改此视图(从中删除视图字段等)。 有趣的是,如果我之前创建了这个个人视图,我可以修改这个视图
In project, I'm currently working on, I have to create personal list view for given list (SharePoint 2007). Here is my code (currList is SPList):
System.Collections.Specialized.StringCollection viewFields = currList.Views[BaseViewID].ViewFields.ToStringCollection();
SPView searchView = currList.Views.Add(SearchViewName, viewFields, query, 100, true, false, Microsoft.SharePoint.SPViewCollection.SPViewType.Html, true);
Everything's working fine when the user has permission to ADD elements to the list. Creating view for user, which has ALL permissions to the list except adding items gives "Access is denied" error. Adding view from SharePoint itself works.
I've found the same problem here:
http://us.generation-nt.com/security-issue-while-creating-personal-view-programmatically-help-86373652.html
so the problem isn't new.
//EDIT:
If I create personal view (having add items to list and manage personal views permissions) I can later modify this view (remove view fields from it, etc.) with manage personal views permnission only.
What's interesting is thatif I've created this personal vier earlier I can modify this view
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您知道从 UI 添加视图是有效的,您可以尝试复制那里发生的情况。
使用firebug,你可以看到发生了什么,基本上ViewNew页面提交到这个url
但是有更多的参数。
如果你确实需要这个功能,可以尝试一下。
If you know that adding views from the UI works, you can try replicating what is happening there.
Using firebug, you can see what is going on, basically the ViewNew page submits to this url
But with a many more parameters.
If you really need this feature, you could try that.
SharePoint 2010 中仍然存在问题。无法从代码中使用“管理个人视图”添加视图,但可以从 UI 中添加视图。作为新项目中的解决方法,我创建了 JS 脚本,该脚本:
我正在使用 jQuery 来执行此操作。单击按钮会导致回发,因此必须对其进行处理:
执行一次就足够了。当您拥有视图后,可以使用管理个人视图权限进行更新。
Problem still exists in SharePoint 2010. Adding views with Manage personal views is not possible from code, but it's possible from UI. As a workaround in new project I've created JS script which:
I'm using jQuery to do this. Clicking button causes postback, so it must be handled:
It's enough to do this once. When you have view then it can be updated with Manage personal views permission.