Changing all users project limit to "0"

Hello!

I`ve been using Gitlab CE for a few months and i need to change all users project creation limit to “0”. I know that i can change this on their settings, but there are a lot of users, is there a way that i can apply a script that do this for me? If so, how do i apply it? is there any API that i have to use or how do i excecute it?

Can use Gitlab API to do this.

https://scm.hue.workslan/help/api/users.md

Didn’t test this but something like below
To get a list of users:
https://scm.hue.workslan/api/v4/users

To update projects limits:
curl -H ‘Content-Type:application/json’ -H ‘Accept:application/json’ -X PUT -d ‘{“projects_limit”:0}’ http:///api/v4/users/?private_token=

==
#!/bin/bash

declare -a USER_IDS=$(curl --insecure -H “PRIVATE-TOKEN: b_BQVCqbRFX233W7sUju” -H ‘Accept:application/json’ -X GET https://scm.hue.workslan/api/v4/users?per_page=10 | jq ‘. | .id’)

for user_id in "{USER_IDS[@]}"; do curl -H 'Content-Type:application/json' -H 'Accept:application/json' -X PUT -d '{"projects_limit":0}' http://<gitlab address>/api/v4/users/{user_id}?per_page=500&private_token=
done

3 Likes

Thank you so much Hozawa! This was very useful and it help my purposes. I appreciate that you took the time to help me.

Hello everyone from 2020!
Thanks for your help! Based on what I found here and on GitLab API Docs I wrote script that can be used to change any data for all users (in my case it was to change projects limit to 0 for all users).
Fell free to check it out: https://github.com/timaparf/Gitlab-API-User-Update-

1 Like

Hi @timaparf,

amazing, thanks a lot for sharing! :handshake:

Cheers,
Michael