SharePoint List Item Permissions

I want to programmatically make it so that users can only see individual items in a list.

Basically in the workflow that starts when an element is created, I am going to do something and notify some people about this element. I also want it to change permissions for an element so that only individual users (viewing runtime based on the contents of the elements) can read this element. Other users with access to the list will see only individual elements, but not all of them. A list item may not necessarily belong, but to the user (s) who needs to see it, so I cannot set list permissions to allow users to see only their own items.

Put this in context if it helps. The list logs tasks for a specific member. Each item in the list is a role assignment that contains a search for a role in the role list and a search for a member in the member list. I do not use the multilookup field in the list of participants for roles, because each role assignment requires additional information contained in it, for example, description, start date ect. Each role has a specific user / group that manages it. I want the user to see only the assignment roles for the roles that they are the manager when switching to this large list of role assignments.

Advice will be greatly appreciated.

+5
source share
1

. ,

        // get list item
        SPListItem item = <your list item>;
        if (!item.HasUniqueRoleAssignments)
        {
            item.BreakRoleInheritance(true);
        }

        // get principal
        SPPrincipal principal = <principal to grant permissions to>;

        // get role definition
        SPRoleDefinition rd = <role that contains the permissions to be granted to the principal>;

        // create role assignment
        SPRoleAssignment ra = new SPRoleAssignment(principal);
        ra.RoleDefinitionBindings.Add(rd);
        item.RoleAssignments.Add(ra);

.

,

  • , .
+10

All Articles