Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Friday, December 02, 2011

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


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