Generate list of users by role via CLI

Generate list of users by role via CLI

by Jonathan Bourland -
Number of replies: 2

Our organization requires that we audit privileged users in our Moodle instance every quarter. I'd like to automate this, so I've been trying to find a way to generate a list of users by role (in any context) via command line. 

I looked through the core Moodle CLI functions and haven't found anything that does what I'm looking for.

Another possibility is to just run a MySQL query against the database. However, I haven't been able to work out the correct query to do this in Moodle's schema as of yet. 

I'm wondering if I'm missing something or if anyone has any suggestion on places to look?

We're using Moodle 3.9.11 on a RedHat server

Average of ratings: -
In reply to Jonathan Bourland

Re: Generate list of users by role via CLI

by Randy Thornton -
Picture of Documentation writers

If you want to go the SQL route, then this query will help you out, All Role Assignments by context from the Ad-hoc contributed reports page. It will show you all the normal role assignments in the site. That's just a basic query, but it can get you started.

It will not show the various permissions overrides however. That's another matter altogether, since those are not, strictly speaking roles but modifications of roles.
Average of ratings: Useful (2)