【问题标题】:Change sharepoint list item permission based on value slected in Person or Group type根据在个人或组类型中选择的值更改共享点列表项权限
【发布时间】:2012-10-09 21:23:12
【问题描述】:

我有一个列表,其中列的类型为人员或组。我的要求是需要将另一个列表项的项目权限更改为上述列中的选定值。

例如,我有两个列表 A 和 B。列表“A”包含“访问”列,其类型为“个人和组”(可以有多个)。我想将列表“B”的项目权限更改为列表 A 的“访问权限”列中的选定值。

指导我如何做到这一点。

【问题讨论】:

  • 你试过什么?您是否阅读了SPList 的文档?什么不清楚?
  • SPPrincipal 主体 = (SPPrincipal) 组; SPRoleAssignment rAssignment = new SPRoleAssignment(group); parentItem.BreakRoleInheritance(true); parentItem.RoleAssignments.Add(principal); parentItem.Update(); 这对我有用。但我不知道如何将值从我的 SPFieldUserValueCollection 获取到 SPGroup 对象。
  • 这对我有用 SPGroup oGroup = web.Groups.GetByID(oFieldUserValue.LookupId);

标签: c# sharepoint sharepoint-list


【解决方案1】:
SPWeb web = SPContext.Current.Web;
SPGroup oGroup = web.Groups.GetByID   (oFieldUserValue.LookupId);   //Look up field value                                     
SPPrincipal principal = (SPPrincipal)oGroup;
SPRoleAssignment roleAssignment = new SPRoleAssignment(principal);                                        
permFolder.Item.BreakRoleInheritance(true);                                        
roleAssignment.RoleDefinitionBindings.Add(web.RoleDefinitions["Contribute"]);
permFolder.Item.RoleAssignments.Add(roleAssignment);
permFolder.Item.Update();
finalItem.Update();  

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-02-05
    • 1970-01-01
    • 1970-01-01
    • 2015-10-15
    • 2011-08-27
    • 2019-11-20
    • 1970-01-01
    • 2014-11-11
    相关资源
    最近更新 更多