Setting Role When Creating New User With MVC?

Mar 31, 2011

Setting role when creating new user with MVC

I am looking at the default MVC 2 controller.

How do I set the role for the new user that is created in the Register method?

Is this possible with just a simple property set or do I have to do something special?

View 1 Replies

Similar Messages:

Security :: Can CreateUserWizard With Creating Dupicate User While Assigning Role

Sep 18, 2010

protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
Roles.AddUserToRole((sender as CreateUserWizard).UserName, "Customers");

CreateUserWizard is creating dupicate user while assigning Role.How can we assign Role without duplicating user record? I've observed ApplicationID for assigning Role is Differenent than Creating New User, so when ever Role assigning comes in, it creates same user again with new UserID. Is it related to Web.Config in some way? As when I try to create user from "VisualStudio/Website/ Configuration"

View 12 Replies

Security :: Creating A Interface For User Role Management Based On Built In Membership Provider?

Feb 18, 2011

I am creating a interface for User Role Management based on built in membership provider.I want to display all the roles as check boxes for a selected user. I am able to display all the roles in the database, but not able to load the specific user roles. For example, I am able to publish role 1 role 2 role3 role 4 as check boxes. But if the user is already flagged as role 1 and role 3, I am not able to show that data (role1 and 3 should be checked when form loads, but right now, they are not checked)...How do I get the roles as checked boxes display on a page.I am using a repeater control to display roles as check boxes on the page..

<asp:Repeater ID="UsersRoleList" runat="server">
<asp:CheckBox runat="server" ID="RoleCheckBox" AutoPostBack="true" Text='<%# Container.DataItem %>'


View 1 Replies

Setting Auth Cookie Timeout Length Based On Role?

May 18, 2010

I want to allow admins to be logged in for longer than normal users. I don't see a hook for setting the cookie timeout programmatically or in a role-based way. Is this possible in ASP using Forms Authentication?

View 2 Replies

VS 2008 Creating Role Based Authorization?

Feb 9, 2011

I have seen articles on Role Based Authorization in MS-Sql but i did not find any article in, i am acheived this concept using session user name i am enabling certain parts of website to group A and certain parts of site to Group B but when i have more groups i cannot use this method.

Myrequirement is:

In Web applications, typically there exist certain parts of the site that only certain folks, or groups of persons can access. For example, imagine Web site used to administer the content on a company's public Internet Web site, where the public Web site lists products sold by the company. From the administrative site, all company employees might be able to make minor changes to the products' descriptions, quantity, and other such non-essential information. However, perhaps only a subset of trusted employees might be able to change the products' prices. And even a smaller subset of employees would be able to add new products or delete existing products from the database I would be delighted if any one provide the solution

View 9 Replies

Localization :: Cannot Fix Or Limit User To Setting PC Regional Setting To UK

Dec 23, 2010

I have develop a web application. I have put my web application in my server and user can access from any location.

My server regional and setting is English (US). Now my problem is

1) When user access to my system and his pc setting is English (UK), it will prompt and error

and after i debug i suspect it is because of Datetime conflict (dd/MM/yyyy and MM/dd/yyyy)

2) I cannot fix or limit my user to setting his/her pc regional setting to UK

So what can i do in my web application solve this issue?

(Can i write any code in my client side (.aspx) to convert or do standardization to US)

View 2 Replies

Security :: Enable User To Edit / Delete Based On User's Role Permission

Feb 24, 2011

I'm trying to allow logged user who are in department XYZ to perform some task for my third party App. I have two SQL tables named Users & UserList. The third party app (GoldMine) graps the USERNAME from the Users table and store it as UserID which I then referecnce SessionID. The UserList table has two columns (GM_UserName & Department) which I'm interested in. When a user login into the 3rd party app (GoldMine), i then compare the USERNAME (from Users table) to GM_UserName (from UserList table) and see whether GM_UserName is in = 'Dept XYZ'. Take a look at the SQL query below.

sqlDept = "SELECT USERNAME FROM Users LEFT JOIN UserList ON UserList.GM_UserName=Users.UserName WHERE UserList.Department ='Dept XYZ'"

I'm able to do this.

If Session("Userid") = "TestUser1" Or Session("UserID") = "TestUser2" Then Do this Else Do that End If
BUT unable to do this...
If user's Department = 'Department XYZ' Then
Do This
Do that
End IF

View 2 Replies

MVC :: Strongly Typed User Control On All Pages Based On Login Status And User Role

May 9, 2010

I want to display a menu (which will be strongly typed with it's own unique model) across all pages only if a user is logged in.What menu items are available depend on the user's role and also I'll need to hit the repository to get numbers like "x Messages", etc

Been scratching my head for a simple solution here. Don't want to create something that need changes all over the place.All my controllers derive from a BaseController, all my Models from BaseViewModel....probably where I'll be implementing functionality for this.

View 3 Replies

User Controls :: Show Hide Specific Section Of Page Based On User Type Or Role

May 7, 2015

I have LOGIN PANEL for student, and I want to disable it in different page. And only the admin can enable and disable it. I dont know the logic behind here.

View 1 Replies

ASP.NET Dynamically Creating & Setting Different ID For The Same Controls?

Aug 26, 2010

is it possible to render the same controls with different ID property ?

<%for (int i = 0; i < 15; i++)
<asp:Label ID='Label<%=i.ToString() %>' runat="server"/>

here is an error: 'Label<%=i.ToString() %>' is not a valid identifier.

View 1 Replies

C# - How To Set User Control Visibility, Upon User Role

Mar 11, 2011

I want to implement access control for usercontrols depending on user role(s), I want to do it on the control base class, in such way that on every user control I only need to set a string with allowed roles to see the user control

This is how an user control class may look like:

public partial class SimpleMenu : MyUsrControlBase
protected void Page_Load(object sender, EventArgs e)[code]...

How to set up user control visibility from the base class depending on the validation result?Also which event in the user control is the best to set the roles?

AlloweRoles = "RoleA, RoleB"

View 1 Replies

C# - Creating Custom Umbraco Data Editor Setting Types?

Feb 17, 2011

I can't seem to find anything on how to edit the data editor settings before umbraco 6.2 (Juno). Is there any simple way, it must be possible. If you don't understand what i mean i want to do the same as [URL]

View 2 Replies

Web Forms :: Add "role" Parameter / Property To User Control Containing LoginView Control To Set "Role" Possible?

Jan 13, 2010

I am in the process of creating a user control that enables content areas of our web application to be editable. The control utilizes the membership/role providers and incorporates a LoginView that only displays the edit link if a user has logged in and is a member of the desired role. What I would like to be able to do is pass the "role" as a property of the control so it can be set dynamically and does not have to be hard coded into the control if I use elsewhere in another application.

View 3 Replies

Visual Studio :: Setting Which Could Stop VS Creating Automatic Styling And Fixing The Alignment?

Feb 27, 2011

I have 2 questions

1)Can I stop VS2008,VS2010 creating automatic style in the VS2008 .aspx source view.e.g .style1{ width=100%"

2) All aligned source view code changes and after certain amount of time,If you could tell me any setting which could stop VS creating automatic styling also fixing the alignment just once.

View 4 Replies

Security :: How To Get The User's Role

Jan 22, 2011

Is there any way that I can find the exact name of the role a User is in? There is a property for UserName ( User.Identity.Name) but what about the role?

View 1 Replies

How To Add User Role Using MS Access DB

Jul 18, 2012

trying to get a login script working, its working fine, but now i have a new problem, i have a field im my DB thats called "urole" in that i have 3 roles, Admin, Co-Admin, User.

How can i use something like this on a page.


If Roles.IsUserInRole("Admin") Then
Label1.Text = User.Identity.Name + " is an Admin"
Label1.Text = User.Identity.Name + " is NOT in an Admin"
End If

I have this script on my login page

Imports System.IO
Imports System.Data
Imports System.Data.OleDb
Imports System.Web.Configuration
Partial Class DbLogin
Inherits System.Web.UI.Page


and then i have this on my default page, thats shows the info from an user, now i just want to show the role (urole) and then use an "If Roles.IsUserInRole" event so i can show some diffrent thing if admin, co-admin or User

Imports System.IO
Imports System.Web.Security
Partial Class _Default
Inherits System.Web.UI.Page


(The aboved is working fine, but its not showing the urole/Role of an user)

View 12 Replies

VS 2008 How To Change The User's Role From One To Another

Feb 18, 2010

In code, how can I change the user's role from one to another?

Let's say the user1 is in Role1. I would like to change his role to Role2.

View 6 Replies

Security :: How To Add Role To New User Upon Creation

Dec 10, 2010

I have a page setup to manage and create users.. in order to help the process of creation, i woudl like to add the new users to our default "users" role when they click the create button. Below is what is in place for the creation page and the button event tied to the button. I used this from a tutorial i found else where, but dont have the link at the moment if anyone needed it.. but the code below works great when creating a new user


View 5 Replies

Programmatically Add User Role To COM+ Component (C#)

Mar 2, 2010

I wish to know the way to add ASP.NET ("Machine_Name"IIS_IUSRS) to user role in COM+ component programmatically using C#. So whenever my COM+ component is being installed, ASP.NET user is created under Role.

View 1 Replies

C# - Get Role Of User In A String Variable?

Jan 21, 2010

is there a way i can get the role in a string variable using the below commands....

System.Security.Principal.WindowsIdentity wi = System.Security.Principal.WindowsIdentity.GetCurrent();
System.Security.Principal.WindowsPrincipal wp = new System.Security.Principal.WindowsPrincipal(wi);

i need this for

FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, // version
UserName.Text, // user name
DateTime.Now, // creation
DateTime.Now.AddMinutes(60),// Expiration
false, // Persistent
role); // User data

as string role= wp.IsInRole();
but this is not right

View 5 Replies

Security :: Can't Save Role Of User

Feb 12, 2011

The roles of users are not saved. Here is what i am doing:


And i added this to the create user wizard:

<asp:WizardStep ID="SpecifyRolesStep" runat="server" StepType="Step"
Title="Specify Roles" AllowReturn="False">
<asp:CheckBoxList ID="RoleList" runat="server">

View 1 Replies

Security :: Get The Role Of The User Using Memebership

Dec 31, 2010

I need to get the role of the user using memebership.

View 2 Replies

XmlSiteMapProvider Check User To Be In Specified Role?

May 22, 2010

I 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"?

View 2 Replies

Verification A User's Role And Approval

Nov 11, 2010

There used to a lot of tutorials on the site and I can't find any of them anymore. Anyway, I'm looking for a tutorial on how to send out an email to the newly registered user for verficiation. After the user checks his/her email and click the link in the email, it automatically unlock the user's account and allow him/her to login to the site. Below is what I have so far:



And verification page_load:

The user does receive the verification email and when he/she click on the link it does come over to the verification.aspx page; however, the user still can't login. When I looked at the status of the user, it's still locked.

View 2 Replies

Security :: Checking User For Particular Role?

Jan 28, 2011

im using forms authentication and created roles.

while the user enters the credentials im authenticating the user with username and password

now i also want to check the particular user whether he is that role.


if username,password are true and role is Admin i redirect him to Adminhome.aspx

else to empHome.aspx.

im able to chek username and password but im unable to detect the role.


View 6 Replies

Copyrights 2005-15, All rights reserved