Add a custom Permission Level using Client Object Model


using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
Microsoft.SharePoint;
using
Microsoft.SharePoint.Client;
namespace
ClientObjectModel
{
class Program
{
static void Main(string[] args)
{

//Add a custom Permission Level

string siteURL = "http://serverName:1111/sites/SPSiteDataQuery/";
ClientContext context = new ClientContext(siteURL);
BasePermissions permissions = new BasePermissions();
permissions.Set(
PermissionKind.AddAndCustomizePages);
permissions.Set(
PermissionKind.AddDelPrivateWebParts);
permissions.Set(
PermissionKind.AddListItems);
RoleDefinitionCreationInformation roleDefinitionCreationInfo = new RoleDefinitionCreationInformation();
roleDefinitionCreationInfo.BasePermissions = permissions;
roleDefinitionCreationInfo.Name =
"Custom Permission Level";
roleDefinitionCreationInfo.Description =
"My Custom Permission Level";
RoleDefinition roleDefinition = context.Web.RoleDefinitions.Add(roleDefinitionCreationInfo);
context.ExecuteQuery();
}
}
}
Ebook Download
View all
Learn
View all