使用SPBasePermissions控制权限

[Contribute]
 SPBasePermissions.ViewPages |
                                                             SPBasePermissions.Open |
                                                             SPBasePermissions.AddListItems |
                                                             SPBasePermissions.EditListItems |
                                                             SPBasePermissions.ViewListItems |
                                                             SPBasePermissions.OpenItems |
                                                             SPBasePermissions.ViewVersions |
                                                             SPBasePermissions.CreateAlerts |
                                                             SPBasePermissions.ViewFormPages |                                                           
                                                             SPBasePermissions.UseClientIntegration |
                                                             SPBasePermissions.ManagePersonalViews |
                                                             SPBasePermissions.ManagePersonalViews |
                                                             SPBasePermissions.UpdatePersonalWebParts |
                                                                 SPBasePermissions.ViewPages




//Create the View Only permission level
            SPRoleDefinition viewOnly = this.EnsureRoleDefinition(web,
                                                                    "View Only",
                                                                    "ReadOnly Permission ",
                                                                    SPBasePermissions.ViewFormPages
                                                                    | SPBasePermissions.ViewListItems
                                                                    | SPBasePermissions.Open
                                                                    | SPBasePermissions.ViewPages);
            
            //Create the Admin permission level
            SPRoleDefinition Admin = this.EnsureRoleDefinition(web,
                                                                        "Admin",
                                                                        "Read, Add Item and Edit Item Permissions",
                                                                       SPBasePermissions.ViewFormPages
                                                                       | SPBasePermissions.ViewListItems
                                                                       | SPBasePermissions.ViewFormPages
                                                                       | SPBasePermissions.Open
                                                                       | SPBasePermissions.ViewPages
                                                                       | SPBasePermissions.AddListItems
                                                                       | SPBasePermissions.EditListItems);

            SPRoleDefinition addOnly = this.EnsureRoleDefinition(web,
                                                                      "Add Only",
                                                                      "Read, Add Item Permissions",
                                                                      SPBasePermissions.ViewFormPages
                                                                      | SPBasePermissions.ViewListItems
                                                                      | SPBasePermissions.ViewFormPages
                                                                      | SPBasePermissions.Open
                                                                      | SPBasePermissions.ViewPages
                                                                      | SPBasePermissions.AddListItems);

            SPRoleDefinition editOnly = this.EnsureRoleDefinition(web,
                                                                      "Edit Only",
                                                                      "Read, Edit Item Permissions",
                                                                      SPBasePermissions.ViewFormPages
                                                                      | SPBasePermissions.ViewListItems
                                                                      | SPBasePermissions.ViewFormPages
                                                                      | SPBasePermissions.Open
                                                                      | SPBasePermissions.ViewPages
                                                                      | SPBasePermissions.EditListItems);

            SPRoleDefinition delete = this.EnsureRoleDefinition(web,
                                                                      "Delete",
                                                                      "Read, Edit, Add, delete Item Permissions",
                                                                      SPBasePermissions.ViewFormPages
                                                                      | SPBasePermissions.ViewListItems
                                                                      | SPBasePermissions.ViewFormPages
                                                                      | SPBasePermissions.Open
                                                                      | SPBasePermissions.ViewPages
                                                                      | SPBasePermissions.EditListItems
                                                                      | SPBasePermissions.AddListItems
                                                                      | SPBasePermissions.DeleteListItems);

            SPRoleDefinition viewVersions = this.EnsureRoleDefinition(web,
                                                                     "View Versions",
                                                                     "Read, Edit, Add, delete Item Permissions",
                                                                     SPBasePermissions.ViewFormPages
                                                                     | SPBasePermissions.ViewListItems
                                                                     | SPBasePermissions.ViewFormPages
                                                                     | SPBasePermissions.Open
                                                                     | SPBasePermissions.ViewPages
                                                                     | SPBasePermissions.EditListItems
                                                                     | SPBasePermissions.AddListItems
                                                                     | SPBasePermissions.DeleteListItems
                                                                     |SPBasePermissions.ViewVersions);

 

posted @ 2013-04-10 13:35  zyip  阅读(416)  评论(0编辑  收藏  举报