SPRoleCollection.GetSpecialRole method
NOTE: This API is now obsolete.
已過時。請改用新的SPRoleDefinition和SPRoleAssignment類別,來定義角色,並將使用者指派給它們。如需詳細資訊,請參閱Changes in the Authorization Object Model。(在Windows SharePoint Services 2.0, GetCollection方法傳回其型別所指定的系統角色和維護回溯相容性。)
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
<ObsoleteAttribute("Use the SPRoleDefinitionCollection class instead")> _
Public Function GetSpecialRole ( _
roleType As SPRoleType _
) As SPRole
'用途
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
)
參數
roleType
Type: Microsoft.SharePoint.SPRoleTypeSPRoleType值,這個值指定的型別。
傳回值
Type: Microsoft.SharePoint.SPRole
SPRole 物件,表示該角色。
Examples
下列程式碼範例會使用GetSpecialRole方法,將指定的使用者新增至目前的站台的Reader角色。
此範例假設包含一個標籤控制項的.aspx 網頁的存在。
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");