This project is read-only.

In a controller: getting name of current user?

Topics: Writing modules
May 21, 2011 at 6:07 PM

In a controller, what call should I make to get the name of the current user and what roles he belongs to?

May 24, 2011 at 4:01 PM

To get the user object that will have user info, you could use Membership.GetUser(). To get the user's actual name, Membership.GetUser().UserName.

To return the list of roles a user is in, see this thread on Stackoverflow:

May 24, 2011 at 4:44 PM

Although -  you might want to use WorkContext.CurrentUser (which accesses the User content item in Orchard) and IRolesService which is an orchard component to inspect the current roles.