清理文档库中的文档角色

发布于 2024-07-09 20:10:56 字数 394 浏览 7 评论 0原文

我一直在开发一个事件处理程序来清理 MOSS 中文档库新项目的 RolesAssignments。 我已经搜索了一种可以有效清理所有 RolesAssignments 的方法,尽管我发现接缝的最佳方法是循环 RolesAssignments 并逐个删除? 是否有其他方法来清理项目的所有 RolesAssignments?

我用于清理 RolesAssignments 的代码如下所示:

    for (int i = ListItem.RoleAssignments.Count - 1; i >= 0; --i)
    { 
        ListItem.RoleAssignments.Remove(i); 
    }

有人对如何处理这个问题有任何想法吗?

I have been developing an event handler to clean up the RolesAssignments of the new item of a document library in MOSS. I’ve searched for a method that could clean all the RolesAssignments efficiently, although the best way I found seams to be loop through the RolesAssignments and delete one by one? Is there another way to clean all the RolesAssignments for an item?

The code I’m using for cleaning the RolesAssignments look like this:

    for (int i = ListItem.RoleAssignments.Count - 1; i >= 0; --i)
    { 
        ListItem.RoleAssignments.Remove(i); 
    }

Does anyone have any ideas on how to deal with this?

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

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

发布评论

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

评论(3

短叹 2024-07-16 20:10:56

您在问题正文中给出的示例是执行此操作的最正确方法。 ResetRoleInheritance 和 BreakRoleInheritance 可能会满足您的需要,但这是它们执行的操作的副作用。 它们的目的不是删除 RoleAssignments,而是对角色继承进行操作。 来自 MSDN:

ResetRoleInheritance - “删除本地角色分配并恢复到父对象的角色分配。”

BreakRoleInheritance - “为以下对象创建唯一的角色分配物品,而不是从父母那里继承它们。”

如果角色继承已被破坏并且您正在使用特定的角色分配,则应使用问题中的循环删除它们。

The example you've given within the body of your question is the most correct way to do this. ResetRoleInheritance and BreakRoleInheritance may do what you need, but this is the side-effect of the operations they perform. Their purpose is not to remove RoleAssignments, but rather operate on role inheritance. From MSDN:

ResetRoleInheritance - "Removes the local role assignments and reverts to role assignments from the parent object."

BreakRoleInheritance - "Creates unique role assignments for the item rather than inheriting them from a parent."

If role inheritance is already broken and you are using specific role assignments, you should remove them using a loop as you have in your question.

烧了回忆取暖 2024-07-16 20:10:56

我有答案,放置属性 SPListItem.BreakRoleInheritance(false) 来中断角色继承并删除角色分配。

I have the answer, put the propertie SPListItem.BreakRoleInheritance(false) to break the role inheritance and remove the role assignments.

夏有森光若流苏 2024-07-16 20:10:56

重置角色继承怎么样? 这应该清除所有角色分配。

How about ResetRoleInheritance? This should clear out all of the RoleAssignments.

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