Share via


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 方法。

GetRolesForCurrentUser调用 方法会SelectingProvider引发 事件。

注意

不要从在 Web 服务器上执行的代码中调用 GetRolesForCurrentUser 方法。 仅作为 WCF 服务的一部分调用 GetRolesForCurrentUser 方法。 有关如何在 Web 服务器上执行的代码中读取用户角色的详细信息,请参阅 GetRolesForUser 方法。

适用于

另请参阅