views:

180

answers:

3

I'm using ASP.NET MVC Framwork and trying to grok the ASP Membership 3.5 stuff.

What is the best way to add the first administrator user without having to log in? I've been staring at the membership starter kit's source without finding it.

+2  A: 

Depends on what memebership provider your are using.. If your using a SQL memembershipprovider you should be able to use the regular Asp.Net Configuration tool. (Project menu -> Asp.Net Configuration)

Richard L
Sweet. But say if I share the project with other developers and it would be nice to have the same user set-up done between them. Is there some way to do so?
Spoike
If your using SQL memembershipprovider, just make them all use the same database. If the other projects are not in house, i guess OpenID or Passport would be a better choice.
Richard L
+4  A: 

A simple solution (especially or rather only for dev. purposes) by doing it in a "setup" action:

if (!Roles.RoleExists("Administrator"))
{
    Roles.CreateRole("Administrator");
}
if (Membership.GetUser("Admin") == null)
{
    Membership.CreateUser("Admin", "Admin");
}
veggerby
+1  A: 

You said you were going to share the project. I would recommend creating a one-time-run page that creates the user and assigns it the roel you want. After that any concurrent runs of the page should than check for the user you want and if it exists to redirect away or some other mechanic.

Chad Moran