using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint.Client;
namespace GowthamSamples
{
class Program
{
static void Main(string[] args)
{
// ClientContext - Get the context for the SharePoint Site
ClientContext clientContext = new ClientContext("http://gauti.sharepoint.com/sites/sp1/");
GroupCollection Groups = context.Web.SiteGroups;
// Assume that there is a "Owners" group, and the ID=7.
Group ownersGroup = Groups.GetById(7);
// Let's set up the new user info.
UserCreationInformation userCreationInfo = new UserCreationInformation();
userCreationInfo.Email = "[email protected]";
userCreationInfo.LoginName = "sharepointdev\\gowtham";
userCreationInfo.Title = "User";
// Let's add the user to the group.
User newUser = ownersGroup.Users.Add(userCreationInfo);
context.ExecuteQuery();
}
}
}
Thanks for reading my Blogs!