A weak 'admin' [2.7]

A weak 'admin' [2.7]

by Visvanath Ratnaweera -
Number of replies: 9
Picture of Particularly helpful Moodlers Picture of Translators
The user 'admin' of a 2.7 site doesn't get the Site-administration menu. Trying https://example.com/admin/ throws "Sorry, but you do not currently have permissions to do that (Change site configuration)" pointing to https://docs.moodle.org/27/en/error/moodle/nopermissions.

I don't know the history of the site, but I have no reason to believe that the owners have tampered with roles and permissions.

I checked the table mdl_user and there is nothing unusual in the record with id=2:
| id | auth   | confirmed | policyagreed | deleted | suspended | mnethostid | username | password ...
| 2 | manual | 1 | 0 | 0 | 0 | 1 | admin | [gibberish] ...

Am I missing something obvious?
Average of ratings: -
In reply to Visvanath Ratnaweera

Re: A weak 'admin' [2.7]

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Possibly... they're not an admin. 

As all capability checks for site admin come back true then a capability error is impossible for the site admin.  Find the mdl_config table in the database and search for name='siteadmins'. The value field contains a comma-separated list of the current site admin's user ids. 

Average of ratings: Useful (1)
In reply to Howard Miller

Re: A weak 'admin' [2.7]

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
I thought, that was it! But still missing:
mysql> select * from mdl_config where name="siteadmins";
+----+------------+-------+
| id | name | value |
+----+------------+-------+
| 19 | siteadmins | 2 |
+----+------------+-------+

So my admin with id=2 is there?

Still something is wrong. I know that there is another systemwide admin. Will check.
In reply to Visvanath Ratnaweera

Re: A weak 'admin' [2.7]

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

There isn't. That's the only place the site admins are defined. Site admins completely skip the role system. The has_capability() and require_capability() calls simply return 'true' if your id is in that list. 

Average of ratings: Useful (1)
In reply to Howard Miller

Re: A weak 'admin' [2.7]

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi Howard,

That is more an IRC! Thanks!!

No, I was just too exicted, and logged in to the wrong server!
sad

In the real one, id=2 was indeed missing:
mysql> select * from mdl_config where name="siteadmins";
+----+------------+-------------+
| id | name | value |
+----+------------+-------------+
| 19 | siteadmins | 108,102,116 |
+----+------------+-------------+

Ran the update command and got:
| 19 | siteadmins | 2,108,102,116 |

But this admin is still "weak". Even a logout/login didn't help. I am still investigating.
In reply to Visvanath Ratnaweera

Re: A weak 'admin' [2.7]

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi Howard

Here comes a late report. As I wrote earlier, the SQL update didn't help. I returned after the weekend, and it works!

I don't have an explanation other than that some cache has delayed the effect.
Average of ratings: Useful (1)
In reply to Visvanath Ratnaweera

Re: A weak 'admin' [2.7]

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

If that's what you want to believe... big grin big grin

In reply to Howard Miller

Re: A weak 'admin' [2.7]

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
I don't know what to believe. I wish I had taken the subtle path of asking the strong admin to promote the weak admin (in the web GUI). I think, that is what Mary proposed.
smile
In reply to Visvanath Ratnaweera

Re: A weak 'admin' [2.7]

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators

Hi Visvanath - it's probably beyond my knowledge, but can you at least confirm that this user 'admin' does appear in the list of site admins in yourmoodlesite/admin/roles/admins.php?

In reply to Mary Cooch

Re: A weak 'admin' [2.7]

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Mary

That would have been too nice. This weak 'admin' can not kick open anything under mysite/admin/ !
sad

Let me see whether Howard's interrogation would do. Still good to know that you are only minutes away.
wink