SPRoleCollection class
NOTE: This API is now obsolete.
Use the new SPRoleDefinition and SPRoleAssignment classes instead, to define roles and to assign users to them. For more information, see Authorization object model. (In Windows SharePoint Services 2.0, SPRoleCollection represented a collection of SPRole objects and is maintained for backward compatibility.)
Microsoft.SharePoint.Administration.SPAutoSerializingObject
Microsoft.SharePoint.SPBaseCollection
Microsoft.SharePoint.SPRoleCollection
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Use the Roles property of the SPUser, SPGroup, or SPWeb class to return an SPRoleCollection object that represents the collection of roles for a user, group, or Web site. Use an indexer to return a single role from the collection. For example, if the collection is assigned to a variable named collRoles, use collRoles[index] in C#, or collRoles(index) in Visual Basic, where index is either the index number of the role in the collection or the display name of the site group.
The following code example adds all the users of a site to a specified role for all the subsites under the site.
Note |
|---|
Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects. |
Note