Introduction
Normally, we are having permission level operations in SharePoint. We may assign such kind of permission both manually and programmatically. Here, we will see how to give permission to "Everyone" programmatically
Code
SPUser allUsers = web.AllUsers[@”c:0(.s|true”]; //c:0(.s|true is Everyone
SPRoleDefinitionCollection roleCollection = web.RoleDefinitions;
SPRoleDefinition roleDefinition = roleCollection[“Visitors”];
SPRoleAssignment roleAssignment = newSPRoleAssignment((SPPrincipal)allUsers);
roleAssignment.RoleDefinitionBindings.Add(roleDefinition);
list.BreakRoleInheritance(false);
list.RoleAssignments.Add(roleAssignment);
list.Update();
Powershell script
Set-SPUser -Identity "c:o(.s\true" -web "webUrl" -Group "Visitors"
It is not working, but when I give "Everyone" instead of "c:o(.s\true" it is working and new-spuser command then only its wokring
ReplyDeletenew-spuser -UserAlias "Everyone" -Web "http://testsitecollection" -Group "Approvers"
Thanks a lot for the info Jubair
Delete