JOJ
踏踏实实做人,认认真真做事!放纵自己就是毁灭自己!

原文地址 : http://www.cnblogs.com/Kenr/archive/2009/04/02/1428240.html

在MOSS页面上设置自定义权限级别,可以进入以下页面进行操作

  1. 在“网站设置”页上的“用户和权限”下,单击“高级权限”。
  2. 在工具栏上,单击“设置”,然后单击“权限级别”。

代码实现:

using (SPWeb oWebsite = SPContext.Current.Site.AllWebs["Subsite_Name"])

{

    SPRoleDefinitionCollection collRoles = oWebsite.RoleDefinitions;

//取得名为【Definition_Name】的自定义权限级别

    SPRoleDefinition oRoleDefinition = collRoles["Definition_Name"];

//定义【Definition_Name】所拥有的权限

    oRoleDefinition.BasePermissions = SPBasePermissions.FullMask ^

        SPBasePermissions.ManagePermissions;

//不要忘记更新

    oRoleDefinition.Update();

}

代码解析:

(1)当给自定义权限级别添加基本权限时,可以使用以下符号

  • & - bitwise AND
  • ^ - exclusive OR
  • | - inclusive OR

例:

1) oRoleDefinition.BasePermissions |= SPBasePermissions.ManageSubwebs;

Retains the current permissions mask but adds ManageSubwebs to the mask.

2) oRoleDefinition.BasePermissions ^= SPBasePermissions.CreateSSCSite;

Retains the current permissions mask but removes CreateSSCSite from the mask.

3) oRoleDefinition.BasePermissions &= SPBasePermissions.CreateAlerts;

Reduces the permissions mask so that it only contains CreateAlerts.

(2)下面是能够在自定义权限级别里添加的基本权限一览

英文及中文环境

Member name

Description

AddAndCustomizePages

Add, change, or delete HTML pages or Web Part Pages, and edit the Web site using a Windows SharePoint Services–compatible editor. 

AddDelPrivateWebParts

Add or remove personal Web Parts on a Web Part Page. 

AddListItems

Add items to lists, add documents to document libraries, and add Web discussion comments. 

ApplyStyleSheets

Apply a style sheet (.css file) to the Web site. 

ApplyThemeAndBorder

Apply a theme or borders to the entire Web site. 

ApproveItems

Approve a minor version of a list item or document. 

BrowseDirectories

Enumerate files and folders in a Web site using Microsoft Office SharePoint Designer 2007 and WebDAV interfaces. 

BrowseUserInfo

View information about users of the Web site. 

CancelCheckout

Discard or check in a document which is checked out to another user. 

CreateAlerts

Create e-mail alerts. 

CreateGroups

Create a group of users that can be used anywhere within the site collection. 

CreateSSCSite

Create a Web site using Self-Service Site Creation. 

DeleteListItems

Delete items from a list, documents from a document library, and Web discussion comments in documents. 

DeleteVersions

Delete past versions of a list item or document. 

EditListItems

Edit items in lists, edit documents in document libraries, edit Web discussion comments in documents, and customize Web Part Pages in document libraries. 

EditMyUserInfo

Allows a user to change his or her user information, such as adding a picture. 

EmptyMask

Has no permissions on the Web site. Not available through the user interface. 

EnumeratePermissions

Enumerate permissions on the Web site, list, folder, document, or list item. 

FullMask

Has all permissions on the Web site. Not available through the user interface. 

ManageAlerts

Manage alerts for all users of the Web site. 

ManageLists

Create and delete lists, add or remove columns in a list, and add or remove public views of a list. 

ManagePermissions

Create and change permission levels on the Web site and assign permissions to users and groups. 

ManagePersonalViews

Create, change, and delete personal views of lists. 

ManageSubwebs

Create subsites such as team sites, Meeting Workspace sites, and Document Workspace sites. 

ManageWeb

Grant the ability to perform all administration tasks for the Web site as well as manage content. Activate, deactivate, or edit properties of Web site scoped Features through the object model or through the user interface (UI). When granted on the root Web site of a site collection, activate, deactivate, or edit properties of site collection scoped Features through the object model. To browse to the Site Collection Features page and activate or deactivate site collection scoped Features through the UI, you must be a site collection administrator. 

Open

Allow users to open a Web site, list, or folder to access items inside that container. 

OpenItems

View the source of documents with server-side file handlers. 

UpdatePersonalWebParts

Update Web Parts to display personalized information. 

UseClientIntegration

Use features that launch client applications; otherwise, users must work on documents locally and upload changes.  

UseRemoteAPIs

Use SOAP, WebDAV, or Microsoft Office SharePoint Designer 2007 interfaces to access the Web site. 

ViewFormPages

View forms, views, and application pages, and enumerate lists. 

ViewListItems

View items in lists, documents in document libraries, and view Web discussion comments. 

ViewPages

View pages in a Web site. 

ViewUsageData

View reports on Web site usage. 

ViewVersions

View past versions of a list item or document. 

 

参考MSDN:

http://msdn.microsoft.com/zh-cn/library/microsoft.sharepoint.sproledefinition.basepermissions.aspx

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spbasepermissions.aspx

 

Technorati 标签: moss,Permissions,权限
posted on 2011-03-12 09:29  JoinJ  阅读(515)  评论(0编辑  收藏  举报