代码创建自定义权限级别

自定义权限级别,日文系统下的名字是【アクセス許可レベル

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.  

 

日文环境

メンバ名

説明

AddAndCustomizePages

HTML ページまたは Web パーツ ページを追加、変更、または削除し、Windows SharePoint Services 互換エディタを使用して Web サイトを編集します。 

AddDelPrivateWebParts

Web パーツ ページ上で個人用 Web パーツを追加または削除します。 

AddListItems

リストにアイテムを追加し、ドキュメント ライブラリにドキュメントを追加して、Web ディスカッション コメントを追加します。 

ApplyStyleSheets

Web サイトにスタイル シート (.css ファイル) を適用します。 

ApplyThemeAndBorder

Web サイト全体にテーマまたは枠線を適用します。 

ApproveItems

リスト アイテムまたはドキュメントのマイナー バージョンを承認します。 

BrowseDirectories

Microsoft Office SharePoint Designer 2007 および WebDAV インターフェイスを使用して、Web サイト内のファイルおよびフォルダを列挙します。 

BrowseUserInfo

Web サイトのユーザーに関する情報を表示します。 

CancelCheckout

別のユーザーに対してチェックアウトされたドキュメントを破棄またはチェックインします。 

CreateAlerts

電子メール通知を作成します。 

CreateGroups

サイト コレクション全体で使用できるユーザーのグループを作成します。 

CreateSSCSite

Self-Service Site Creation を使用して Web サイトを作成します。 

DeleteListItems

リストからのアイテムの削除、ドキュメント ライブラリからのドキュメントの削除、およびドキュメント内の Web ディスカッション コメントの削除を行います。 

DeleteVersions

リスト アイテムまたはドキュメントの古いバージョンを削除します。 

EditListItems

リスト内のアイテム、ドキュメント ライブラリ内のドキュメント、およびドキュメント内の Web ディスカッション コメントの編集、およびドキュメント ライブラリ内の Web パーツ ページのカスタマイズ。 

EditMyUserInfo

ユーザーに対して、各自の情報の変更 (画像の追加など) を許可します。 

EmptyMask

Web サイト上でのアクセス許可は持っていません。ユーザー インターフェイスによって使用することはできません。 

EnumeratePermissions

Web サイト、リスト、フォルダ、ドキュメント、またはリスト アイテム上でのアクセス許可を列挙します。 

FullMask

Web サイト上ですべてのアクセス許可を持っています。ユーザー インターフェイスによって使用することはできません。 

ManageAlerts

Web サイトのすべてのユーザーに対する通知を管理します。 

ManageLists

リストを作成および削除し、リスト内の列を追加または削除して、リストのパブリック ビューを追加または削除します。 

ManagePermissions

Web サイト上でのアクセス許可レベルを作成および変更し、ユーザーおよびグループにアクセス許可を割り当てます。 

ManagePersonalViews

リストの個人用ビューを作成、変更、および削除します。 

ManageSubwebs

チーム サイト、会議ワークスペースのサイト、ドキュメント ワークスペースのサイトなどのサブサイトを作成します。サイト コレクションを対象範囲とするフィーチャーのプロパティをアクティブ化、非アクティブ化、または編集します。[サイト コレクションの機能] ページを参照し、サイト コレクションを対象範囲とするフィーチャーをユーザー インターフェイスを介してアクティブ化または非アクティブ化するには、サイト コレクションの管理者である必要があります。 

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 page and activate or deactivate site collection scoped Features through the UI, you must be a site collection administrator. 

Open

ユーザーに対して、Web サイト、リスト、またはフォルダを開いて、そのコンテナ内のアイテムにアクセスすることを許可します。 

OpenItems

サーバー側のファイル ハンドラでドキュメントのソースを表示します。 

UpdatePersonalWebParts

Web パーツを更新して、個人用設定情報を表示します。 

UseClientIntegration

クライアント アプリケーションを起動する機能を使用します。そうしなければ、ユーザーはドキュメントに対してローカルで作業を行い、変更内容をアップロードする必要があります。 

UseRemoteAPIs

SOAPWebDAV、または Microsoft Office SharePoint Designer 2007 インターフェイスを使用して Web サイトにアクセスします。 

ViewFormPages

フォーム、ビュー、およびアプリケーション ページを表示し、リストを列挙します。 

ViewListItems

リスト内のアイテム、ドキュメント ライブラリ内のドキュメントを表示し、Web ディスカッション コメントを表示します。 

ViewPages

Web サイトのページを表示します。 

ViewUsageData

Web サイトの利用状況に関するレポートを表示します。 

ViewVersions

リスト アイテムまたはドキュメントの古いバージョンを表示します。 

 

 

参考:

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

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

 

 

posted on 2009-04-02 15:52  阿米巴原虫  阅读(679)  评论(0编辑  收藏  举报