Hi Stas,

You do not impersonate within the script, hence your code actually checks 
if the *current user* has *ADMINISTER* permission fo *user u*.

Example of a working code: 
https://github.com/jenkinsci/ownership-plugin/blob/0c8e5e65a78567bb152ee1c906620c9c66ea8820/src/main/java/com/synopsys/arc/jenkins/plugins/ownership/util/userFilters/AccessRightsFilter.java#L55-L74
 
. You will need to replace the checked item by 
Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)

четверг, 10 ноября 2016 г., 12:29:56 UTC+1 пользователь Stas Roshkolets 
написал:
>
> Hello, I am trying to write Groovy script that will  identify users that 
> they are assigned as admins in Jenkins :
>
> import jenkins.model.Jenkinsimport hudson.model.Userimport 
> hudson.security.Permission
>
> allUsers = User.getAll()
> adminList = []for (u in allUsers) {
>  if (u.hasPermission(Jenkins.ADMINISTER)) {
>  // if (u.canDelete()) {
>    adminList.add(u)
>   }}
> println allUsers 
> println adminList
>
>
> Both lists allUsers, adminList print all users in the system...
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/1266cbb1-38ae-4f45-a999-db98ce0ed14b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to