RoleService.GetRolesForCurrentUser 方法

定義

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

public:
 cli::array <System::String ^> ^ GetRolesForCurrentUser();
[System.ServiceModel.OperationContract]
public string[] GetRolesForCurrentUser ();
[<System.ServiceModel.OperationContract>]
member this.GetRolesForCurrentUser : unit -> string[]
Public Function GetRolesForCurrentUser () As String()

傳回

String[]

使用者所屬角色的名稱陣列。

屬性

例外狀況

未啟用角色管理。

備註

方法 GetRolesForCurrentUser 會傳回使用者的所有角色。 GetRolesForCurrentUser當您必須檢查或保留所有使用者的角色,以判斷哪些資源可供使用者使用時,請使用 方法。 您可以使用這個方法來避免多次呼叫 IsCurrentUserInRole 方法。

呼叫 方法會 GetRolesForCurrentUserSelectingProvider 引發 事件。

注意

請勿從 Web 服務器上執行的程式碼呼叫 GetRolesForCurrentUser 方法。 您只會呼叫 GetRolesForCurrentUser 方法做為 WCF 服務的一部分。 如需如何在 Web 服務器上執行的程式碼中讀取使用者角色的詳細資訊,請參閱 GetRolesForUser 方法。

適用於

另請參閱