RoleDefinition クラス
Defines a single role definition, including a name, description, and set of rights.
継承階層
System.Object
Microsoft.SharePoint.Client.ClientObject
Microsoft.SharePoint.Client.RoleDefinition
名前空間: Microsoft.SharePoint.Client
アセンブリ: Microsoft.SharePoint.Client.Silverlight (Microsoft.SharePoint.Client.Silverlight.dll 内); Microsoft.SharePoint.Client.Phone (Microsoft.SharePoint.Client.Phone.dll 内) Microsoft.SharePoint.Client (Microsoft.SharePoint.Client.dll 内)
構文
'宣言
Public NotInheritable Class RoleDefinition _
Inherits ClientObject
'使用
Dim instance As RoleDefinition
public sealed class RoleDefinition : ClientObject
例
This code example creates a new permission level and adds a user to the Announcements list with that permission level.
using System;
using Microsoft.SharePoint.Client;
namespace Microsoft.SDK.SharePointFoundation.Samples
{
class RoleDefinitionExample
{
static void Main()
{
string siteUrl = "http://MyServer/sites/MySiteCollection";
ClientContext clientContext = new ClientContext(siteUrl);
Site collSite = clientContext.Site;
Web site = clientContext.Web;
// Set up permissions.
BasePermissions permissions = new BasePermissions();
permissions.Set(PermissionKind.ViewListItems);
permissions.Set(PermissionKind.AddListItems);
permissions.Set(PermissionKind.EditListItems);
permissions.Set(PermissionKind.DeleteListItems);
// Create a new role definition.
RoleDefinitionCreationInformation rdcInfo = new RoleDefinitionCreationInformation();
rdcInfo.Name = "Manage List Items";
rdcInfo.Description = "Allows a user to manage list items";
rdcInfo.BasePermissions = permissions;
RoleDefinition roleDef = collSite.RootWeb.RoleDefinitions.Add(rdcInfo);
// Create a new RoleDefinitionBindingCollection object.
RoleDefinitionBindingCollection collRDB = new RoleDefinitionBindingCollection(clientContext);
// Add the role to the collection.
collRDB.Add(roleDef);
// Get the list to work with and break permissions so its permissions can be managed directly.
List targetList = site.Lists.GetByTitle("Announcements");
targetList.BreakRoleInheritance(true, false);
// Get the RoleAssignmentCollection for the target list.
RoleAssignmentCollection collRoleAssign = targetList.RoleAssignments;
// Add the user to the target list and assign the user to the new RoleDefinitionBindingCollection.
RoleAssignment rollAssign = collRoleAssign.Add(site.CurrentUser, collRDB);
clientContext.ExecuteQuery();
Console.WriteLine("Security modified");
}
}
}
スレッド セーフ
この型のパブリック static (Visual Basic のShared ) メンバーはいずれもスレッド セーフです。インスタンス メンバーはスレッド セーフになるという保証はありません。