Sign in
Home
Library
Wiki
Learn
Gallery
Downloads
Support
Forums
Blogs
Resources For IT Professionals
United States (English)
Россия (Pусский)
中国(简体中文)
Brasil (Português)
Post an article
Translate this page
Powered by
Microsoft® Translator
Wikis - Page Details
First published by
Ed Price - MSFT
(Microsoft)
When:
5 Mar 2012 6:33 AM
Last revision by
Ed Price - MSFT
(Microsoft)
When:
29 Dec 2012 8:53 AM
Revisions:
10
Comments:
4
Options
Subscribe to Article (RSS)
Share this
Can You Improve This Article?
Positively!
Click Sign In to add the tip, solution, correction or comment that will help other users.
Report inappropriate content using
these instructions
.
Wiki
>
TechNet Articles
>
SharePoint 2010: How to Manage Permissions
SharePoint 2010: How to Manage Permissions
Article
History
SharePoint 2010: How to Manage Permissions
This article will show you how to manage user permissions inside of SharePoint 2010. This enables you to change the read and write permissions for individuals and groups of users across your organization.
NOTE
: Please add more information when it becomes available.
Example 1. How to set permissions to SPListItem.
public
void
SetSPListItemUserPermissions
(
SPListItem
listItem,
SPUser
user,
SPRoleType
roleType)
{
//Break role inheritance
if
(!listItem.
HasUniqueRoleAssignments
)
listItem.
BreakRoleInheritance
(
false
);
listItem.
Update
();
//Create new role
var
roleDefinition = listItem.
Web
.
RoleDefinitions
.
GetByType
(roleType);
var
roleAssignment =
new
SPRoleAssignment
(user);
roleAssignment.
RoleDefinitionBindings
.
Add
(roleDefinition);
//Assign new role
listItem.
RoleAssignments
.
Add
(roleAssignment);
listItem.
Update
();
}
Example 2. How to restore permissions to SPListItem
public
void
RestoreSPListItemUserPermissions
(
SPListItem
listItem)
{
if
(listItem.
HasUniqueRoleAssignments
)
listItem.
ResetRoleInheritance
();
listItem.
Update
();
}
Example 3. How to create new permissions level
public
void
CreateNewPermissionsLevel
(
SPWeb
web,
string
title,
string
description,
SPBasePermissions
basePermissions,
bool
copyRoleAssignments,
bool
keepRoleAssignments)
{
if
(!web.
HasUniqueRoleDefinitions
)
web.
RoleDefinitions
.
BreakInheritance
(copyRoleAssignments, keepRoleAssignments);
web.
Update
();
var
roleDefinition =
new
SPRoleDefinition
{
Name
= title,
Description
= description,
BasePermissions
= basePermissions
};
web.
RoleDefinitions
.
Add
(roleDefinition);
}
EAA
,
Ed Price
,
Ed's Stub Pages
,
en-US
,
ESA
,
Permissions
,
SharePoint
,
SharePoint 2010
,
stub
,
stub (en-US)
Sort by:
Published Date
|
Most Recent
|
Most Useful
Comments
Hemendra Agrawal
4 May 2012 5:31 AM
Good one
Page 1 of 1 (1 items)