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 new user to a particular group
string siteURL = "http://serverName:1111/sites/SPSiteDataQuery/";
ClientContext context = new ClientContext(siteURL);
GroupCollection groupColl = context.Web.SiteGroups;
Group group = groupColl.GetById(7);
UserCreationInformation userCreationInfo = new UserCreationInformation();
userCreationInfo.Email = "";
userCreationInfo.LoginName = @"DomainName\UserName";
userCreationInfo.Title = "SharePoint Developer";
User user = group.Users.Add(userCreationInfo);
context.ExecuteQuery();
}
}
}