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)
{
//Assign the custom permission Level to the user
string siteURL = "http://serverName:1111/sites/SPSiteDataQuery/";
ClientContext context = new ClientContext(siteURL);
User user=context.Web.EnsureUser(@"DomainName\UserName");
RoleDefinition roleDefinition=context.Web.RoleDefinitions.GetByName("Custom Permission Level");
RoleDefinitionBindingCollection roleDefinitionBindingColl=new RoleDefinitionBindingCollection (context);
roleDefinitionBindingColl.Add(roleDefinition);
RoleAssignment roleAssign=context.Web.RoleAssignments.Add(user,roleDefinitionBindingColl);
context.ExecuteQuery();
}
}
}