RoleDefinitionBindingCollection - Classe
Spécifie les définitions de rôle liées à un objet d’attribution de rôle.
Hiérarchie d’héritage
System.Object
Microsoft.SharePoint.Client.ClientObject
Microsoft.SharePoint.Client.ClientObjectCollection
Microsoft.SharePoint.Client.ClientObjectCollection<RoleDefinition>
Microsoft.SharePoint.Client.RoleDefinitionBindingCollection
Espace de noms : Microsoft.SharePoint.Client
Assemblys : Microsoft.SharePoint.Client.Silverlight (dans Microsoft.SharePoint.Client.Silverlight.dll); Microsoft.SharePoint.Client.Phone (dans Microsoft.SharePoint.Client.Phone.dll) Microsoft.SharePoint.Client (dans Microsoft.SharePoint.Client.dll)
Syntaxe
'Déclaration
Public NotInheritable Class RoleDefinitionBindingCollection _
Inherits ClientObjectCollection(Of RoleDefinition)
'Utilisation
Dim instance As RoleDefinitionBindingCollection
public sealed class RoleDefinitionBindingCollection : ClientObjectCollection<RoleDefinition>
Exemples
Cet exemple de code crée un nouveau niveau d'autorisation et ajoute un utilisateur dans la liste annonces à ce niveau d'autorisation.
using System;
using Microsoft.SharePoint.Client;
namespace Microsoft.SDK.SharePointFoundation.Samples
{
class RoleDefinitionBindingCollectionExample
{
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");
}
}
}
Cohérence de thread
Tous les membres statique (Partagé dans Visual Basic)s publics de ce type sont thread-safe. Cela n’est pas garanti pour les membres d’instance.