Namespace :-
using Microsoft.SharePoint.Client;
ClientContext objContext = new ClientContext("------"); //Site collection URL
using Microsoft.SharePoint.Client;
Source Code:-
ClientContext objContext = new ClientContext("------"); //Site collection URL
GroupCreationInformation objCreateInfo = new GroupCreationInformation();
objCreateInfo.Title = TextBox2.Text;
Group objGroup = objContext.Web.SiteGroups.Add( objCreateInfo);
RoleDefinition objDefination = objContext.Web. RoleDefinitions.GetByName (" Contribute"); //PermissionLevel
RoleDefinitionBindingCollectio n objBindingColl =
new
RoleDefinitionBindingCollection(objContext);
objBindingColl.Add( objDefination);
objContext.Web. RoleAssignments.Add(objGroup, objBindingColl);
objContext.ExecuteQuery();
No comments:
Post a Comment