Some possible inspiration in this thread:
Basically you interrogate the user source using the system functions then build that up into a response.
Put together, something like this:
def getUsersWithRole(userSource, role):
return filter(
lambda u: role in u.roles,
system.user.getUsers(userSource)
)
return [
dict(
username = user.get(user.Username),
**{ci.contactType: ci.value for ci in user.contactInfo}
)
for user in getUsersWithRole("myUserSource", "administrator")
]