Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Group Class
Collapse the table of content
Expand the table of content

Group Class

Represents a group on a Microsoft SharePoint Foundation Web site.

Namespace:  Microsoft.SharePoint.Client
Assemblies:   Microsoft.SharePoint.Client.Silverlight (in Microsoft.SharePoint.Client.Silverlight.dll);  Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)

[ScriptTypeAttribute("SP.Group", ServerTypeId = "{e54ad5f1-ce4e-453b-b7f7-aea6556c9c40}")]
public class Group : Principal

Group represents a collection of users. Every group can be represented by an SPMember object and has a unique member identifier.

This code example adds the current user to the visitors group on the current site.

using System;
using Microsoft.SharePoint.Client;

namespace Microsoft.SDK.SharePointFoundation.Samples
    class GroupExample
        static void Main()
            string siteUrl = "http://MyServer/sites/MySiteCollection";

            ClientContext clientContext = new ClientContext(siteUrl);
            Web site = clientContext.Web;
            GroupCollection collGroup = site.SiteGroups;

            // Get the visitors group, assuming its ID is 4.
            Group visitorsGroup = collGroup.GetById(4);

            User currentUser = site.CurrentUser;
            UserCollection collUser = visitorsGroup.Users;


            Console.WriteLine(currentUser.Title + " added to group " + visitorsGroup.Title);

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
© 2015 Microsoft