how to get all the jenkins users through api
You can get the list of Users using below:-
https://<yourjenkins>/asynchPeople/api/xml?depth=1
Get all the Jenkins user using the below code in jenkinsfile:-
import hudson.model.UserUser.getAll().each { user -> println user}
Please refer the link for more information: