Hard cap on the total number of users per Nextcloud instance. Hooks
BeforeUserCreatedEvent and aborts creation once the configured ceiling
is reached - covers the web UI, occ user:add, the provisioning API and
the registration app.
Not available for now
Copy the folder into the app container's custom_apps/, then enable:
docker cp userlimit <app_container>:/var/www/html/custom_apps/userlimit
docker exec -u www-data <app_container> php occ app:enable userlimitFor a compose setup that does not persist /var/www/html, bind-mount the
app read-only instead of copying, and enable it from a startup hook:
volumes:
- ./apps/userlimit:/var/www/html/custom_apps/userlimit:ro# hooks/before-starting/10-userlimit.sh (idempotent, safe every boot)
php occ app:enable userlimit || true
php occ config:app:set userlimit limit --value=5Default cap is 5 (enforced immediately on enable)
occ config:app:set userlimit limit --value=10
occ config:app:get userlimit limit
occ config:app:set userlimit limit --value=0 # 0 or negative = disabledStructured entries land in nextcloud.log. The blocked-attempt line logs
at warning (visible at the default loglevel); permit/debug lines need
loglevel <= 1 in config.php.
occ log:watch
grep userlimit /var/www/html/data/nextcloud.log | jqcountUsers()counts every backend, LDAP included. To cap local accounts only, count the Database backend specifically.- Enforces at the application layer. Raw SQL writes to
oc_usersbypass it; add a DB trigger if that is in your threat model. - Existing accounts above the cap are never touched — the hook only fires on new creations.
- NC 34's typed AppConfig is strict about value types; the listener
degrades to the default on
AppConfigTypeConflictException. To clear a bad value:occ config:app:delete userlimit limit, then set it again.