Create Site Group in SharePoint using CSOM

The example in this topic show how to use CSOM to Create Site Group in SharePoint

  • using Microsoft.SharePoint.Client;
  • using System.Linq;
  •  
  • using (ClientContext clientContext = new ClientContext("http://MyServer/sites/MySiteCollection"))
  • {
  • // NOTE: The user who is running the code will be added as "Group Ownr"
  • GroupCollection oGroupCollection = clientcontext.Web.SiteGroups;
  •  
  • // GroupCreationInformation object
  • GroupCreationInformation oGroupCreationInformation = new GroupCreationInformation();
  •  
  • oGroupCreationInformation.Title = "New Group";
  • oGroupCreationInformation.Description = "Group description";
  •  
  • Group oGroup = oGroupCollection.Add(oGroupCreationInformation);
  • clientcontext.ExecuteQuery();
  • }

Thank you for reading this article. This code was tested in SharePoint 2013


© 2019 Code SharePoint