Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
372 HOUR 17: Securing SharePoint 2010 Using the SharePoint Security Object Model SharePoint enables you to do everything that you can do in security through the user interface also through the SharePoint object model. Table 17.1 lists the various classes and objects related to security. TABLE 17.1 Class and Objects for SharePoint Security Object Model Description An enumeration that represents the built-in permissions available in SharePoint Represents a permission level in SharePoint Defines a SharePoint group Represents the permission levels assigned to a SharePoint group or user Represents a user in SharePoint 2010 Class/Object Name SPBasePermissions SPRoleDefinition SPGroup SPRoleAssignment SPUser The following code illustrates creation of a new permission level: // create a new permission level SPRoleDefinition roleDefinition = new SPRoleDefinition(); // assign some permissions to the new permission level roleDefinition.BasePermissions = SPBasePermissions.AddListItems | SPBasePermissions.BrowseDirectories | SPBasePermissions.DeleteListItems | SPBasePermissions.EditListItems | SPBasePermissions.ManageLists | SPBasePermissions.OpenItems | SPBasePermissions.ViewListItems | SPBasePermissions.ViewVersions; roleDefinition.Name = "Test Role"; web.RoleDefinitions.Add(roleDefinition); You can see the newly created permission level in Figure 17.16. FIGURE 17.16 The Test Role permission level