SPRoleCollection.GetSpecialRole method
NOTE: This API is now obsolete.
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, the GetCollection method returned a system role specified by its type and is maintained for backward compatibility.)
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'Declaration
<ObsoleteAttribute("Use the SPRoleDefinitionCollection class instead")> _
Public Function GetSpecialRole ( _
roleType As SPRoleType _
) As SPRole
'Usage
Dim instance As SPRoleCollection
Dim roleType As SPRoleType
Dim returnValue As SPRole
returnValue = instance.GetSpecialRole(roleType)
[ObsoleteAttribute("Use the SPRoleDefinitionCollection class instead")]
public SPRole GetSpecialRole(
SPRoleType roleType
)
Parameters
roleType
Type: Microsoft.SharePoint.SPRoleTypeAn SPRoleType value that specifies the type.
Return value
Type: Microsoft.SharePoint.SPRole
An SPRole object that represents the role.
Examples
The following code example uses the GetSpecialRole method to add a specified user to the Reader role on the current site.
The example assumes the existence of an .aspx page that contains a label control.
Dim site As SPWeb = SPContext.Current.Web
Dim roles As SPRoleCollection = site.Roles
Dim role As SPRole = roles.GetSpecialRole(SPRoleType.Reader)
role.AddUser("User_Name", "E-mail_Address", "User_Display_Name",
"Notes")
SPWeb oWebsite = SPContext.Current.Web;
SPRoleCollection collRoles = oWebsite.Roles;
SPRole oRole = collRoles.GetSpecialRole(SPRoleType.Reader);
oRole.AddUser("User_Name", "E-mail_Address", "User_Display_Name",
"Notes");