Monday, October 25, 2010

Create Users and Add them to a Group using Client Object Model

Create Users and Add them to a Group using Client Object Model

//get the connection

ClientContext ctx = new ClientContext(“http://SPSite”);

//get the group

Group grp = ctx.Web.SiteGroups.GetById(GroupId); -> get group id ( See Post Get all users and
groups client object model sharepoint 2010

//create the user object
UserCreationInformation usr = new UserCreationInformation();

usr.LoginName = “Domain\isha”;

usr.Email = “ikapoo@Oursite.com”;

usr.Title = “Programmer”;

//add it to the group

grp.Users.Add(usr);

//execute the query to add the user

ctx.ExecuteQuery();

No comments:

Post a Comment