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.

Example 1. How to set permissions to SPListItem.

public void SetSPListItemUserPermissions(SPListItem listItem, SPUser user, SPRoleType roleType)
    //Break role inheritance
    if (!listItem.HasUniqueRoleAssignments)
    //Create new role
    var roleDefinition = listItem.Web.RoleDefinitions.GetByType(roleType);
    var roleAssignment = new SPRoleAssignment(user);
    //Assign new role

Example 2. How to restore permissions to SPListItem

public void RestoreSPListItemUserPermissions(SPListItem listItem)
    if (listItem.HasUniqueRoleAssignments)

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);
    var roleDefinition = new SPRoleDefinition
                                    Name = title,
                                    Description = description,
                                    BasePermissions = basePermissions