RoleDefinitionCollection class
Represents the collection of RoleDefinition objects that define the role definitions that are available for use within the Web site.
Inheritance hierarchy
System.Object
Microsoft.SharePoint.Client.ClientObject
Microsoft.SharePoint.Client.ClientObjectCollection
Microsoft.SharePoint.Client.ClientObjectCollection<RoleDefinition>
Microsoft.SharePoint.Client.RoleDefinitionCollection
Namespace: Microsoft.SharePoint.Client
Assembly: Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)
Syntax
'Declaration
Public NotInheritable Class RoleDefinitionCollection _
Inherits ClientObjectCollection(Of RoleDefinition)
'Usage
Dim instance As RoleDefinitionCollection
public sealed class RoleDefinitionCollection : ClientObjectCollection<RoleDefinition>
Examples
This code example defines a new role and adds it to the role definitions collection.
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);
}
}
}
Thread safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.