語言

RoleService 類別

定義

允許以 WCF Web 服務存取 ASP.NET 角色提供者。

public ref class RoleService
[System.ServiceModel.Activation.AspNetCompatibilityRequirements(RequirementsMode=System.ServiceModel.Activation.AspNetCompatibilityRequirementsMode.Required)]
[System.ServiceModel.ServiceBehavior(ConcurrencyMode=System.ServiceModel.ConcurrencyMode.Multiple, InstanceContextMode=System.ServiceModel.InstanceContextMode.Single, Namespace="http://asp.net/ApplicationServices/v200")]
[System.ServiceModel.ServiceContract(Namespace="http://asp.net/ApplicationServices/v200")]
public class RoleService
[<System.ServiceModel.Activation.AspNetCompatibilityRequirements(RequirementsMode=System.ServiceModel.Activation.AspNetCompatibilityRequirementsMode.Required)>]
[<System.ServiceModel.ServiceBehavior(ConcurrencyMode=System.ServiceModel.ConcurrencyMode.Multiple, InstanceContextMode=System.ServiceModel.InstanceContextMode.Single, Namespace="http://asp.net/ApplicationServices/v200")>]
[<System.ServiceModel.ServiceContract(Namespace="http://asp.net/ApplicationServices/v200")>]
type RoleService = class
Public Class RoleService
繼承
RoleService
屬性

備註

RoleService 物件允許您透過 Windows Communication Foundation(WCF)服務讀取使用者的角色。 要使用角色服務,您必須在網頁伺服器上啟用角色服務,然後將相容於 WCF 的用戶端應用程式連接到該網頁服務。 關於如何設定角色服務的資訊,請參閱 「如何啟用 WCF 角色服務」。

使用者必須經過認證才能讀取其角色。 角色服務可搭配任何形式的 ASP.NET 驗證。 關於如何透過 WCF 服務登入使用者的資訊,請參見 Windows Communication Foundation 認證服務概述。

這個 RoleService 類別暴露了兩個只能透過 WCF 服務存取的方法:方法 GetRolesForCurrentUser 與方法 IsCurrentUserInRole 。 此 GetRolesForCurrentUser 方法會回傳登入使用者的所有角色。 該方法判斷 IsCurrentUserInRole 使用者是否處於指定角色。

這個RoleService物件提升了事件。SelectingProvider 你要為事件建立一個事件處理程序 SelectingProvider ,在執行時選擇要使用哪個角色提供者。

關於如何從主控台應用程式使用 WCF 角色服務的範例,請參見 Walkthrough: Using ASP.NET Application Services。

建構函式

名稱 Description
RoleService()

初始化 RoleService 類別的新執行個體。

方法

名稱 Description
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設哈希函式。

(繼承來源 Object)
GetRolesForCurrentUser()

會回傳登入使用者的所有角色。

GetType()

取得目前實例的 Type。

(繼承來源 Object)
IsCurrentUserInRole(String)

判斷已登入的使用者是否屬於指定角色。

MemberwiseClone()

建立目前 Object的淺層複本。

(繼承來源 Object)
ToString()

傳回表示目前 物件的字串。

(繼承來源 Object)

事件

名稱 Description
SelectingProvider

當實 RoleService 例決定使用哪個角色提供者來檢查使用者的角色時,會發生這種情況。

適用於

另請參閱