{sharepoint} Setting List Item Permissions Programatically in sharepoint
List in Sharepoint item setting permissions
2023-09-14 09:01:22 时间
namespace Avinash
{
class Program
{
static void Main(string[] args)
{
SetListItemPermission();
}
static void SetListItemPermission ()
{
//Get SPWeb object
SPSite Site = new SPSite("http://<url>");
SPWeb Web = Site.OpenWeb();
//Get Role Definition
SPRoleDefinition RoleDefinition = Web.RoleDefinitions.GetByType(SPRoleType.Administrator);
//Get SPListItem
SPList List = Web.Lists["<list name>"]; // Or you can use Web.GetList method for better performance
SPListItem ListItem = List.Items[1];
//Create new Role Assignment
SPRoleAssignment RoleAssignment = new SPRoleAssignment("<login name>",
"<email address>",
"<display name>",
"");
RoleAssignment.RoleDefinitionBindings.Add(RoleDefinition);
//Break permission if necessary
if(!ListItem.HasUniqueRoleAssignments)
{
ListItem.BreakRoleInheritance(true);
}
//Add Role Assignment to SPListItem's Role Assignment Collection
ListItem.RoleAssignments.Add(RoleAssignment);
ListItem.Update();
}
}
}
相关文章
- Sort List
- [TS] Implement a doubly linked list in TypeScript
- {sharepoint} Setting List Item Permissions Programatically in sharepoint
- sharepoint2010:The number of items in this list exceeds the list view threshold, which is 20000 items.
- Python中实现对list做减法操作介绍
- Java中List集合去除重复数据的方法
- [Algorithm] 1290. Convert Binary Number in a Linked List to Integer
- [React] Return a list of elements from a functional component in React
- [Python] Understand List Comprehensions in Python
- [LeetCode] Delete Node in a Linked List
- 【Python】list 列表中递归插入数据
- SAP UI5 Dropdown list binding debugging
- SAP Spartacus organization unit list的实现Component
- 如何创建SAP C4C Product list并用OData服务消费
- How to identify the product settype and attribute in a given list
- 2019t1_sumdoc_list.txt aa.docx acc baidu v2 sbb.docx Acc jindon v2 sbb.docx assetsList.html Atiitt 日本刑法典读后笔记.docx Atiti 遇到说花心的时候赞美应对.docx Atitit lesson.docx Atitit malye主义、mzd思想和dsp理论的区别和联系.docx Ati
- 成功解决极其刁钻bug之TypeError: ‘<=‘ not supported between instances of ‘list‘ and ‘int‘
- 【mysql】In aggregated query without GROUP BY, expression #1 of SELECT list contains ......
- 《STL源代码分析》---stl_list.h读书笔记
- leetcode 237. Delete Node in a Linked List
- python3.列表 list