English 中文(简体)
• 如何使用户与用户相关的作用从原样式识别物体中获取?
原标题:how to get Roles associated with a user from asp.net FormsAuthentication object?

How to get Roles associated with a user from asp.net FormsAuthentication object? Other than IsInRole I don t see any methods useful in this respect. I am looking for something like GetRoles(). All I usee is User.IsInRole("rolename") and I need to loop through my roles to find my role of iterest. is there a way to get roles from Formsauthticket itself?

问题回答

实际上,使用户发挥作用的守则可以是:

Roles.GetRolesForUser(WebSecurity.CurrentUserName);

我现在请您发言。 Websecurity.CurrentUserName,以获得目前用户的用户名。

你们可以尝试利用其他东西:

Roles.GetRolesForUser("afzaal_ahmad_zeeshan")

<afzaal_ahmad_zeeshan 是用户名称,你们希望获得这些用户的作用。

并请注意,这为你提供了一个<代码>String[的阵列,这样使用foreach ( loop)可能是过滤结果的解决办法。

http://msdn.microsoft.com/en-us/library/8h930x07.aspx” rel=“nofollow” http://msdn.microsoft.com/en-us/library/8h930x07.aspx





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签