This project is read-only.

Deleted Admin user, how to restore or fix?

Topics: Developer Forum, Localization Forum, Project Management Forum, User Forum
May 8, 2009 at 1:34 AM

SOS Folks,

I need help! We have heavily been using MWPSK to share documents and postings at the office. The lady who was supposed to be in charge of user management decided to delete the user admin (which has administrative priviledges) then created another one called pwradmin ( and forgot to assign administrative rights to it!!!!!)

I have read all the suggestion on this site, seems like our only hope is to reset the user list which would mean losing 60 users. Is there a way to restore the admin user without losing everything else?


May 8, 2009 at 1:48 AM

Hi there,

It should be possible to copy the admin user from an original copy of the users.config file, (available from this site, if you don't have an original), and paste it into your existing file.  Doing so should re-instate the "admin" user, along with it's default password of "admin".

I've not tested this, but it should work.  If not, let us know.




May 8, 2009 at 1:57 AM

Thanks you however In order for this to work, I would have to remove the current users.config - thus losing the 60 users information. I can later re-enter the users manually but on local testing shows me that the passwords can not be imported this way as they are encrypted - any thoughts?

May 8, 2009 at 7:39 AM

Users.config is an XML format text file - You can copy a user from one copy of the file and paste in into another. I have used this to recover the Admin user several times. Backup the original first!

May 8, 2009 at 10:58 AM

Alternatively if you can do this in a temporary page... that you can create.... use this code...


        //This will create a admin user and the default Roles - when there are NO users/roles in the database...
        MembershipCreateStatus status;
        Membership.CreateUser("admin", "admin", "", "Answer with yes", "yes", true, Guid.NewGuid(), out status);

        foreach (String roleName in Roles.GetAllRoles())
            if (!Roles.RoleExists(roleName))

        // Add the "admin" user to the Administrators role
        Roles.AddUserToRole("admin", MyWebPagesStarterKit.RoleName.Administrators.ToString());

May 8, 2009 at 12:34 PM

As myriadit says, it should be possible to copy the one admin user from one file to another, without losing existing users, (e.g. copy and paste partial content directly between files).  In addition, itmachines method should also work. 

Lastly, you could just add your existing pwradmin user to the admin roles group using:

void Page_Load(object sender, EventArgs e)
    Roles.AddUserToRole("pwradmin", MyWebPagesStarterKit.RoleName.Administrators.ToString());

to a new, empty *.aspx.cs file.  Then, simply browse to the new file.

You're correct that passwords are encrypted, (hashed in fact), but the method used is portable from machine to machine, (hence, when the original package is downloaded from here, it's admin user's password is "admin", regardless of who downloads it).


May 19, 2009 at 5:01 AM

I recreated the code provided by Itmachines in websites.aspx and it worked thus saved the 60 other users from losing their jobs.

Thank you!!!

May 29, 2009 at 4:23 PM

If someone still regain this problem.
Copy a working users.config to app_data. Ensure that the website is recompiled and then login again.(Clears the cache and you can login again as admin)