RoleService.GetRolesForCurrentUser 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
傳回已登入使用者的所有角色。
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 方法。
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應