Thursday, June 2, 2016

Add group to the list with View only permissions

Add group to the list with  View only (Role definition)- permissions

  webElevated.AllowUnsafeUpdates = true;
                string libGrpName = list.Title + "_ViewOnly";
                SPGroup grp = webElevated.SiteGroups[libGrpName];

SPRoleAssignment roleAssignmentAdmin = new SPRoleAssignment((SPPrincipal)grp);
                SPRoleDefinition roleAdmin = webElevated.RoleDefinitions["View only"];
                roleAssignmentAdmin.RoleDefinitionBindings.Add(roleAdmin);
                list.RoleAssignments.Add(roleAssignmentAdmin);
                list.Update();

                webElevated.AllowUnsafeUpdates = false;

No comments:

Post a Comment