How do i, as Admin, pull list of all user's roles without requiring their passwords!?

if i want a list of users and their roles, how do i pull that list without (and this boggles me) requiring their passwords? from what i can glean, system.security.getUserRoles() takes not only username as a param, but also that user's password, which, as a SecEng makes my eyes pop. so i know i am missing something here. i should be able, as an Admin, to poll user data without compromising their credentials this way. i neither need nor want to have access to user credentials.

EDIT: corrected copy/paste error.

Where did you find that function ?

Anyway, you can use system.user.getUser and call the returned object's .getRoles method.

3 Likes

You could use the management component in Vision, or download the exchange resource for Perspective (not sure which you are using as you didn't flag your post)

https://docs.inductiveautomation.com/display/DOC80/Managing+Users+and+Roles#ManagingUsersandRoles-ManagingUsers

apologies! copy/paste malfunction. should read system.security.getUserRoles()

i'll read through it, but cursory peek does not appear to satisfy the programmatical reqs. i'm not interested in a UI; i need to pull this data in and work with it in subsequent code. requiring user input is not possible for this context. regardless, thank you for the resource.

Use pascal's first suggestion.

3 Likes

but this still requires that i KNOW the user's username. i want to simply poll the project and pull the list of users associated with it, then determine their roles. at present, i can either do that for the currently logged-in user (me, whoopee.) or, i have to provide a username (prognostically determined).

we have, literally, thousands of users. there's no way i am going to keep a list of them all to manually feed into downstream funcs. i fully realize and accept that my Python experience is more of a handicap to me at this point. and i also accept that i am jumping right into the pool, water-wings be damned. but this very basic thing should still be straight-forward and simple, no? if not, not an issue; please educate me.

i should also mention, we do not use Vision at all. exclusively Perspective.

Maybe this will help:

user = system.user.getUser("default", "admin")
print user.roles

users = system.user.getUsers("default")
print users

for user in users:
	print user.roles
2 Likes

If you bothered to look up system.user.getUser() in the manual, it would have been hard to miss system.user.getUsers() right below it.

:man_shrugging:

It is. But as most simple and straight forward things, you need to know it's there. Which is why it's important to carefully read the doc, and particularly the functions' page in this case.

make no mistake, i am very willing to read the docs. knowing what the hell i am looking for is another thing altogether. i wish i had several weeks to sit and read from start to finish; i do not. i have three days. and the guy before me didn't document ANYTHING. so, yes. my questions are seemingly stupid and misguided. but i haven't the luxury i normally would. i literally started five days ago having never touched Ignition. so it's a bit of a fun-sandwich... so big thanks to @ jlandwerlen for just getting right to it, and a nod of appreciation to @ pascal.fragnoud who recognized that i didn't even know where to look in the first place. i am running on shitty code, no documentation, and Ignition noob-juice.