I don't now an way to get all users from categories.
this
class core_course_category
give you all information about categories.Example
$coursecat = core_course_category::get($category)
than you get all courses
core_course_category::search_courses()
and for each course you get all users