Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The SPGroup class represents a cross-site group on a SharePoint Web site.
System.Object
Microsoft.SharePoint.SPGroup
Public Methods
The following table shows the public methods of the SPGroup class and a brief description of each.
| Name | Description | 
|---|---|
| AddUser(Microsoft.SharePoint.SPUser) | Adds the specified user to the cross-site group. | 
| AddUser(String, String, String, String) | Adds the user specified by user name, e-mail address, display name and notes to the cross-site group. | 
| RemoveUser | Removes the specified user from the cross-site group. | 
| ToString | Returns the name of the cross-site group. | 
| Update | Updates the database with changes to properties of the cross-site group. | 
Public Properties
The following table shows the public properties of the SPGroup class, the data type of each property, and a brief description of each.
| Name | Data Type | Description | 
|---|---|---|
| Description | String | Gets or sets the description for the cross-site group. | 
| ID | Int32 | Gets the member ID for the cross-site group. | 
| Name | String | Gets or sets the name of the cross-site group. | 
| Owner | Microsoft.SharePoint.SPMember | Gets or sets the owner for the cross-site group, which can be a user or another cross-site group. | 
| ParentWeb | Microsoft.SharePoint.SPWeb | Gets the parent Web site for the cross-site group. | 
| Roles | Microsoft.SharePoint.SPRoleCollection | Gets the collection of site groups to which the cross-site group belongs in the current site. | 
| Users | Microsoft.SharePoint.SPUserCollection | Gets a collection of user objects that represents all the users in the cross-site group. | 
| Xml | String | Gets the properties of the cross-site group as XML. | 
Thread Safety
Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread safe.
Remarks
To return a single cross-site group, use the Groups property of the SPRole, SPUser, or SPWeb class to return the collection of cross-site groups for the site group, user, or Web site. Otherwise, use the OwnedGroups property of the SPUser class to return the collection of cross-site groups owned by a user, or the SiteGroups property of the SPWeb class to return all the cross-site groups in the site collection.
Use an indexer to return a single cross-site group from the collection. For example, if the collection is assigned to a variable named myGroups, use myGroups[index] in C#, or myGroups(index) in Visual Basic .NET, where index is either the index number of the cross-site group in the collection or the name of the cross-site group.
Every cross-site group has a unique member ID, has the permissions associated with that membership, and can be represented by an SPMember object. The following example assigns a cross-site group to an SPMember object:
SPMember myMember = site.SiteGroups["Cross-Site_Group_Name"];
While a site group can be assigned permissions directly, a cross-site group needs to be added to a site group in order to be assigned permissions. Cross-site groups can be members of site groups. For general information about cross-site groups and security, see Security, Users, and Groups Overview.
Example
The following code example changes the name, owner, and description of a cross-site group in a site collection.
This example requires using directives (Imports in Visual Basic) for both the Microsoft.SharePoint and Microsoft.SharePoint.WebControls namespaces.
Requirements
Namespace: Microsoft.SharePoint
Platforms: Microsoft Windows Server 2003
Assembly: Windows SharePoint Services (in Microsoft.SharePoint.dll)
Security: Code Access Security