1

I am not using Membership or Identity. I am using web-forms based authentication. It's a product i'm working on. and i want the customers to be able to create an admin at the first run (deployment). I'm using RBAC. For now the user creation goes something like:

  • when clicked on the register link on the home page, the account/register controller is run.
  • it presents a form, and user can fill in details, hit submit and create a user.
  • then it sends the user to an admin page(all the 3 points here would be under admin privileges). where all the users are listed. and you can change the role there. on this page there's a link that can transfer the user to add more roles.

what i want:

  • when the applications is first run, it should create an admin role.
  • send the user to registration page(but also, after making sure it's the first run or making sure there's no admin user yet)
  • after that the same page would require admin authentication(this i have implemented in a separate project so i can use that.)

I have tried to add some code in global.asax in application_start() and calling the account/register in configuration.cs. but if i'm not wrong that would run on migration, right?

even if one of those two is the best solution, i'd like to know which one is considered the "best practice" for such problem.

so, how can i go about doing that? any suggestion is welcome. thanks in advance.

Mridul Kashyap
  • 704
  • 1
  • 5
  • 12
  • On the first run, would the first registered user automatically assume the role of administrator? – WorkSmarter Feb 09 '15 at 08:07
  • yes, because basically, i want the admin to be the top on the hierarchy. If i have one admin, i can create many. I've edited my question a bit. stating what i have tried or cosidered. please take a look. – Mridul Kashyap Feb 09 '15 at 10:20

0 Answers0