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 方法。
呼叫該GetRolesForCurrentUser方法會提升事件。SelectingProvider
Note
不要從網頁伺服器上執行的程式碼呼叫該 GetRolesForCurrentUser 方法。 你只會在 WCF 服務中呼叫這個 GetRolesForCurrentUser 方法。 欲了解更多如何在網頁伺服器執行的程式碼中讀取使用者角色的資訊,請參閱此 GetRolesForUser 方法。