setting a default role for a user

Is it possible to set a default role for someone once they've filled in the form from the create user wizard? For instance if once you successfully entered all the data and clicked the buttob your default role would be  set to user.'user'. If so, how can I accomplish this. Also I am using VS 2005 to build the website and I am using the MySql Membership providers.

12/11/2008 3:34:52 AM 27051 articles. 1 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 51

Hi Sojan,

Use the Created User Event of CreateUserWizard and assign newly created user to "User" Role

protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
            Roles.AddUserToRole(Username, "User"); //Use the newly created username here

Mark as Answer if it helps you
12/11/2008 4:35:41 AM

The easiest way (I guess) would be to add the user to your default role right after it has been successful created. I'm thinking about something like the code below.

MemberShipUser user = MemberShip.CreateUser("UserName", "Password");
if ( user != null)
    Role.AddUserToRole(user.UserName, "DefaultRole");

If you are using the Create User Wizard control, you may link the user to the role in the CreatedUser event of the CreateUserWizard control which is handled AFTER the user has successful been created. 


"Dream as if you'll live forever, live as if you'll die today" (James Dean)
12/11/2008 4:46:01 AM

Both answers were great! Thank you both. I gave the answer to the first  one I received.

12/11/2008 2:03:36 PM

Similar Artilces:

Creating User Account Without Default Security Role (Registered User Role)
  My DNN version is 3.1.1. The portal is set to Private Registration. Unauthenicated users have access to the basic pages of the site. We require my company's current customers to register and be approved to have access to all other pages that contain information restricted to them (the major part of the site). As you know, authorizing a user account applys the Registered User security role by default and this is how I control access to the customer areas.  We want to create a page that will be used by Marketing to allow potential customers by login to...

How to set a default role for new users?
Sorry if this question has been asked before but I was unable to find it. How do I assing a default role like "guest" to new users? I am using the CreateUserWizard to let new members enter their information. If you look at the starter kits, (like the club starter kit) they automatically create the roles in the global.asax file in case they are not there. Then, in the createuserwizard's "CreatedUser" event, you add code that assigns the role to the current user. something like: Roles.AddUserToRole(CreateUserWizard1.UserName, AvailableRoles.Items[i].Value);    http://weblogs...

How is the default Role for a new registered user set?
I've been digging through the C# Personal Site Starter Kit code, and I cant seem to figure out how it assigns roles to new users. How is this determined?And how would one configure this?thanks It doesn't add roles to users, you do. Go to the file menu in VWD and select Website -> ASP.NET Configuration. You will then be presented with a web site where you can add roles, users, approve users, and add users to roles. Alternatively you can add some code to the registration page that adds the registered users to the "Friends" role. You will have to set the CreateUserWizard property of "Dis...

Setting up default roles upon user registration
Hello,I wish for all users registering on our site to be assigned the "user" role automatically.All dealers will be assigned a dealer role by us only.The user & dealer roles have been created in the web.config.How would we go about this?Many thanks!  I just picked the answer to this one up earlier today... wouldn't ya know it... Anyway, the solution I was guided through was creating a stored procedure that adds a new entry in the UsersInRoles table, which should have been created automatically. The SP required two inputs: one, the unique identifier for the user, and the name ...

Set default settings for new users
I don't know if this is even possible, but here goes. I have about 5 users for our desktop computer, 1 adult, 3 kids and me (I don't count as an adult :P). There are some settings I want to have each of the environments default to, where they can then change them as they wish on their own. Instead of setting them one-at-a-time, is there a way to modify the settings on the template of what goes into a user's /home directory when they are created? Examples: Set it so when I add a person to the system their - default browser is set to Firefox - starting home ...

Security Policy setting for ASPNet user in .Net 1.1
How would I change the security policy in web.config file for ASPNet user in .Net Framework 1.1, so that this user has the right to create a custom event log and also custom event log sources? This would allow creation of custom event logs in a dynamic manner through .Net code. Normally, only an admin user can create new custom event logs on a machine and if you try to create a custom log or source in code using methods in EventLog class, then the method fails because the ASPNet user under whom the code is executing does not have permission to create the event log.    s...

BUG: error when default user role is set to 2 (project manager)
When I change the default user role in the webconfig file from administrator to project manager, then try and register a new user, I get an error message: "Object reference not set to an instance of an object" with a description: "An unhandled exception occurred during the execution of the current web request" Please help!! Ye there is the bug that if the Project manager is not assigned to a project it goes wrong The problem is this sql statment if any can see the problem then pleas tell me so ELSE IF @RoleID = 2 BEGIN SELECT DISTINCT TT...

Microsoft Security Advisory (892313): Default Setting in Windows Media Player Digital Rights Management Could Allow a User to Open a Web Page Without Requesting Permission
followup to Microsoft Security Advisory (892313): Default Setting in Windows Media Player Digital Rights Management Could Allow a User to Open a Web Page Without Requesting Permission ----------------------------------------------------------- Quote ----------------------------------------------------------- In March 2005, Microsoft issued an update to Windows Media Player to address the issue discussed in this advisory. Microsoft was made aware that malicious attackers can potentially create media files ...

Cannot open user default database. Login failed. Login failed for user 'DOMAIN\User'. (.Net SqlClient Data Provider)
Hi when i try and open a database in sql server management studio i get the error "Cannot open user default database. Login failed. Login failed for user 'DOMAIN\User'. (.Net SqlClient Data Provider)", what can i do to rectify this, i have googled around and still havent found no answers. Which authentication mode is your Sql Server configured - MixedMode, Windows Authentication or Sql Server Authentication? Please refer to and    Ple...

How to set Default Role
I Have 2 Roles in my web Site.... Admins and NormalUser, how can i set "NormalUser" as default role for new users I don't want to place newly created users in Admins.Thanx in Advance... in your script section:       Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As System.EventArgs)        Roles.AddUserToRole(CreateUserWizard1.UserName, "NormalUser")    End Suband in your wizard::<asp:CreateUserWizard                 ...

Default user role
Hello all, What is the default user role of a new user? /Treg The role of a new user depends on the mode how he is registered: - if the user registers himself with REGISTER, the role is NULL. That means the user has no role and is 'anybody'. The only advantage for the registered user at this moment is, that the SIGNON-Dialog is hidden. To add some advantages to the user, You must assign the user to a role within the admin-task and assign access/edit of some desktop-modules to the role. - You may directly register a new user within the admin-task and a...

Setting a default role
Hi everyone, Using the 1.4 Portal Starter kit, I am trying to, upon registering, assign a role to the user which is not the portals default "all users". This may not be a hard task , but I am pretty new to this and would appreciate any help thank you Mark Hollas PS: if anyone has had any experience with using PayPal subscription button together with the Portals registration, could you point me in the right direction as to how to make the PayPal button act as the registration button, then pass the form information to the portal database upon PayPals IPN return? Thanks again. M...

Default user role
When ever I use the CreateUserWizard on my website the new user is not apart of any roles that I have set up so it gives him power to do anything. How do I set the default role for all new users?   thanks.  From here:   This is done by handling CreatedUser event of the CreateUserWizard control.protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { Roles.AddUserToRole(CreateUserWizard1.UserName, "NormalUsers"); }Darrell Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you! Thanks. That works well....

Set User Role
Hi,I am using an sql table to authenticate users, if the user is authenticated I am using: FormsAuthentication.SetAuthCookie(Me.Login_Name.Text, True) How would I set the user role for the user?   Regards, Joe Hello, Instead of calling SetAuthCookie , you need to create FormsAuthentication ticket and add the roles through userData, please refer to this article for more details ,   Edit: if you are working with .net 2.0 , and enabled the RolesManager and configured the Membersdhip and roles provider  ...

Web resources about - setting a default role for a user -

Help:Contents/Account settings and maintenance - Wikipedia, the free encyclopedia
Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc. , a non-profit organization.

Mode setting - Wikipedia, the free encyclopedia
Mode setting can be done in kernel space ( Kernel Mode Setting or KMS) or in user space ( User-space Mode Setting , UMS). Doing mode setting ...

5 Facebook Privacy Settings You Must Review Now
Facebook now has five different settings for controlling whether and how you get tagged on the site.

Analysis: Facebook’s New Privacy Settings a Major (and Risky) Step Toward Openness
The upcoming changes to Facebook’s privacy settings will allow users to control who they share information with every time they post a piece ...

'Delusions' setting Australia up for a big budget shock: Ross Garnaut
The case for company tax cuts for large business has not been subject to &quot;rigorous analysis&quot; according to leading economist Ross Garnaut. ...

Setting Up A Successful Exam-Taking Strategy: 3 Tips For Test Preparation
Are you scared? Good! Because if you are, then you are taking final exams seriously.

In pilot program, Uber is setting drivers up with rental cars
Uber is partnering with Enterprise to rent cars to potential Uber drivers for $210 a week in a pilot program that’s launching this week in Denver, ...

NFL Fantasy Football Week 13: Last-Minute Advice for Setting Your Roster - Bleacher Report
It wasn't so long ago when fantasy drafts were fresh, and our rosters were stocked and stable. When that Eddie Lacy and Dez Bryant combo felt ...

Why did Obama choose the Oval Office setting for his speech and then stand behind a lectern?
Shouldn't he have sat at his desk? I see Callum Borchers at The Washington Post has asked the same question: Whatever the impetus, let's get ...

Setting caution aside, Red Sox went all in for an ace
There was little effort at secrecy — actually, make that none — as a rather unusual dinner party took their places at the table at the Southern ...

Resources last updated: 12/11/2015 8:30:29 AM