RoleDefinitionCollection 類別
代表定義角色所使用的網站中使用的RoleDefinition物件的集合。
繼承階層架構
System.Object
Microsoft.SharePoint.Client.ClientObject
Microsoft.SharePoint.Client.ClientObjectCollection
Microsoft.SharePoint.Client.ClientObjectCollection<RoleDefinition>
Microsoft.SharePoint.Client.RoleDefinitionCollection
命名空間: 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 RoleDefinitionCollection _
Inherits ClientObjectCollection(Of RoleDefinition)
'用途
Dim instance As RoleDefinitionCollection
public sealed class RoleDefinitionCollection : ClientObjectCollection<RoleDefinition>
範例
此範例中的程式碼定義新的角色,並將其加入角色定義集合。
using System;
using Microsoft.SharePoint.Client;
namespace Microsoft.SDK.SharePointFoundation.Samples
{
class RoleDefinitionCollectionExample
{
static void Main()
{
string siteUrl = "http://MyServer/sites/MySiteCollection";
ClientContext clientContext = new ClientContext(siteUrl);
Web site = clientContext.Web;
// Set up permissions.
BasePermissions permissions = new BasePermissions();
permissions.Set(PermissionKind.ManagePermissions);
// Create a new role definition.
RoleDefinitionCreationInformation rdcInfo = new RoleDefinitionCreationInformation();
rdcInfo.Name = "Manage User";
rdcInfo.Description = "Role for managing user permissions";
rdcInfo.BasePermissions = permissions;
rdcInfo.Order = 1;
RoleDefinition roleDef = site.RoleDefinitions.Add(rdcInfo);
clientContext.Load(roleDef);
clientContext.ExecuteQuery();
Console.WriteLine("Created role: {0}", roleDef.Name);
}
}
}
執行緒安全
這類型的任何公用 static (共用 於 Visual Basic 中) 成員是安全執行緒。不保證任何執行個體成員都是安全執行緒。