C# - Want To Check What The Current Users Role Is
Jan 31, 2011How do I check in C# what the current users role is, and print it to the screen.
View 3 RepliesHow do I check in C# what the current users role is, and print it to the screen.
View 3 RepliesI just realized after i created a test account i was not in any roles. Is there a way to automically add new users into the role Users? Have i missed this some where?
View 8 Replieshow do i ask if the current user have the specific role ...
like ... if(user is in role)
{
do simthing...
}
I am using active directory to authinticate users and then i want to use .net role management to assign roles to users.?
How can i assign a role in code behind to current user. ?
For some reason I couldn't find it anywhere, how do I find the current user's role in vb.net?
View 3 RepliesHow could users in a "customer" role be retrieved from a MembershipUserCollection?
View 3 Replies I have an application that uses Forms Authentication and Role Management. I have a few users with more than one role associated to the user. Based on certain roles, the navigation menu displays certain menu options.
Right now, if the user has more than one role, the menu shows the items that are in both roles instead of the items that are in the particular role that the user is logged into or currently set to.
I'm creating an Authentication Ticket to log the user in and I'm passing the active user role as follows:
authenticationTicket = New FormsAuthenticationTicket(1, UserName, DateTime.Now, DateTime.Now.AddMinutes(20), False, UserRole)
Is there anyway to set the user to one particular role and have the application see the user in this single role instead of reading all the roles that the user is in?
I am adding users to roles ,, but i think the users are not really connected to the role ??
One othe thing: does this code looks ok:
[code]....
I'm trying to bind a selected user's role to a dropdown-list. The purpose of this is to be able to change said user's role.
I'm attempting this inside a formview hooked up to a linqdatasource which contains a row from the aspnet_User table.
The dropdown list is hooked up to a linqdatasource of all the roles in the aspnet_Roles table (with DataValueField="RoleID", DataTextField="RoleName").
I figured it would be possible with something like:
SelectedValue='<%# Bind("aspnet_UsersInRole[0].aspnet_Role.RoleID") %>'
But this throws a parser exception, about the bind call not being correctly formatted.
The roles are there, they show up when I remove the "SelectedValue"
Is there any reasonably efficient way to get a list of users who are not in a specific role?
The only methods I can see are Get all the users from DB and do a check in code
Go directly to the db and sidestep the role provider
I would like to collect all the emails from all users in a certain role. How would I do this ?
View 1 RepliesHow can I collect all user (guid) from a specific role?
View 3 RepliesI have an asp.net page with a gridview. I would like to make it so that certain columns in the gridview are displayed only if the user is in a certain role, that is, if HttpContext.Current.User.IsInRole(XXX) returns true.
What is the easiest way to do this?
I would prefer a solution where I can easily put this in my ASP code and not in the page code-behind.
How do I get a list of email addresses from everyone in a particular role, so I can loop through and send them an email from my code behind?
I could do it through it by running a query and filling a data container, but it seems like there should a way through the membership class?
I am using the asp.net membership provider tables in sql server. I'm trying to figure out how to query a list of users that are NOT in any role.
View 4 RepliesThere is Role Management feature in ASP.NET It works on local development machine. For our project we need customers admin to be able to create new users and manage their roles. So, basically same what aspnet_regsql.exe does. Question is Should we develop our own pages and forms or use some ready made tool?
View 3 RepliesI roll my own SiteMapProvider inheriting System.Web.XmlSiteMapProvider.I want to override logic of checking user to be in a role specified in siteMapNode's property roles:
<siteMapNode url="Add.aspx?type=user" title="Add user" roles="admin" />
How can I do that? Which class's member does XmlSiteMapProvider call to check that if securityTrimmingEnabled="true"?
I have a simple custom membership provider. And i have a roles table also in my database with 2 roles in, User and admin. I dont think i need to implement the roleprovider as this will be overkill for what i need.
How can i modify the validate user method to route users to one URL and admin to another?
Can i put in a If statement to say If role = admin go here after a user has been validated?
[Code]....
I would like to populate a dropdownlist with all users who are in the Sales role. I am using the .Net Membership and Roles tables in my SQL 2005 DB (aspnet_Users, aspnet_Roles...).
View 3 RepliesUsing ASP.NET (C#) I have set up Authorization Manager to allow me to handle roles on a website. Added users to roles is simple Roles.AddUserToRole("DOMAIN\UserName", "role"). However I want to list the users belonging to a role, but since they are stored as SID's, displaying them would not be that helpful. To get the users, I am thinking XML would have to be used, although is it possible to use COM Interop to both do that and get the user name? Either way, how can I get the users belonging to a role?
The table to manage roles would basically be like this:
Role User
---- ----
admin DOMAINUserName [delete]
DOMAINUserName2 [delete]
[add user text box]
news DOMAINUserName3 [delete]
[add user text box]
I've been reading about asp web administration tool. I read about creating roles and stuff and forcing a controller to use authentication in order to be viewed. My question is, say create on the administration tool a user called Peter and I assign him the Administrator role. Then I want to create another role called LimitedAdministrator. But I want Peter to create new users on his View (I'm using MVC). Can anyone point me in the direction of how to do this.
I want peter to see on his page, like "Create user" and this user will be created as a LimitedAdministrator.
I have repeater which shows a list of users and there roles. There is also a dropdown list to chnage there role see below
<td><asp:DropDownList ID="ddlChangeType" class="controlwidth100" runat="server" AutoPostBack="true" OnSelectedIndexChanged="change" /></td>
the change event works but what I need is the ID of the row so the user can be updated.
I need to check in conditional logic if a user has more that one role associated.Script should work like:
If a user has 1 role CODE OKIf a user has more that 1 role CODE ERRORThe method is
GetRolesForUser();
But I do not know how to use it, could you please give me a sample of code? how to implement it, arrays?
I want to execute some logic if the Logged in User can view a page "~/MyPage.aspx". IF the logged in user should be elligible to view the page is determined by the role based security I configured in the web.config file. There are many methods to find out if the user is in role XXX or not. But I did not find any method to find out if the user can view a page or not ahead of transferring the user to that page. Maybe I will hide a link to a specific page to the logged in user if the user is not elligible to view that page if I know the technique i am asking here to know.
View 1 Replies I use EF 4 and Membership Provider Shipped with ASP.Net 4.0.
I need find all Users in a Specific Role and Populate a DropDownList using List<ListItem>.
DataBase Tables involved are:
[code]....
Problems:
IF return FALSE always, so I am not able to populate List<>.
I suppose I am doing wrong in if an some Properties.