Skip to content

Rake task that adds or removes users from projects respecting LDAP groups

Created by: elvanja

Existing bulk permission rake task (lib/tasks/bulk_add_permission.rake) doesn't take LDAP groups into account. The main idea is:

  • create a LDAP group and add LDAP users to it
  • create a Gitlab project group that has the same name as the above LDAP group
  • run (cron) this script to:
    • add users from LDAP group to all projects within Gitlab group
    • remove users from Gitlab group that are no longer in LDAP group
    • for projects outside any Gitlab group, do as before (all users to all such projects)

The pull request version is for Gitlab that has username, and will try to pair LDAP users with Gitlab users either by email (mail is the LDAP equivalent) or by username. For Gitlab versions <=3.1.0, where username property on User is not available, use this version: https://gist.github.com/4214666. This version is actually tested and running in production (I'm running 3.1.0), but the difference is trivial so it should work too.

Merge request reports

Loading