Admin Accidentally Locked Himself Out - Anybody here able to help?

Admin Accidentally Locked Himself Out - Anybody here able to help?

by Mike Stapleton -
Number of replies: 4

As Admin I accidently moved my Admin Username into a lower level role (student). Now I can not do any of the Admin functions. Since I was the only user with Admin role I know of no way to correct the problem and give myself full Admin role. This is a very bad situation!!!! Any way to reset? I can access the remote server where all Moodle files are and can get at anything in there.

I posted this in General a few days ago but no responses so wondering if anyone in this group can help me get back on track. I am thinking there may be a line or two in somewhere in code where I can reset access to Admin.

Mike

Average of ratings: -
In reply to Mike Stapleton

Re: Admin Accidentally Locked Himself Out - Anybody here able to help?

by LauriBeth Hull -

Can you get to the PHP MySQl admin tool on the server? Then you could find the table where the user's role is set and update it to admin. Of course this suggestion is only good if thatis how you have Moodle set up.

 

LauriBeth

In reply to LauriBeth Hull

Re: Admin Accidentally Locked Himself Out - Anybody here able to help?

by Mike Stapleton -

LauriBeth,

Thanks for quick response. The next reply after yours eluded to the same thing with the steps to correct it manually. If you check my replly to that one and the link to the screencapture you can see where I am at with it so far. Getting closer I think.

Mike

In reply to Mike Stapleton

Re: Admin Accidentally Locked Himself Out - Anybody here able to help?

by Aaron Wells -

I've attached a little PHP script that will do it. Just change the username and (if you've customized the name of the Administrator role) the role name at the top of the file. Then upload it to your moodle directory, and access it via your web browser. Make sure to delete it when you're done (although since it takes no user input, it should be fairly safe).

If you're comfortable using the database, you could instead edit the database records manually. The role assignments are stored in the aptly-named mdl_role_assignments table. You'll also need to look in the mdl_user table to get your userid, the mdl_role table to get the ID of the Administrator role, and the mdl_context table for the id of the system context (select id from mdl_context where contextlevel=10).

Cheers,

Aaron

In reply to Aaron Wells

Re: Admin Accidentally Locked Himself Out - Anybody here able to help?

by Mike Stapleton -

I was able to get into the database via PHPmyAdmin. Found all the tables. My userid is 2 the ID of the Admin is 1 and the system context is 1 at contextlevel=10. I went back to mdl_role_assignments table opened edit and changed userid to 1 BUT got a error notice.

I did a quick screencapture video showing all tables in the database and the error. I did not have my microphone available so no sound but used the cursur to highlight entries. Maybe if you took a peek at that you could see where I went wrong.

Video is on ScreenCast at http://www.screencast.com/t/wikOFzBi3

Thanks for your help.

I will be out on a jobsite all day so won't be able to check back in until tonight.

Attachment mdl_role_assignments.png