20170529132120_ldap_multi_group_mapping.rb 763 B

123456789101112131415161718192021222324252627
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class LdapMultiGroupMapping < ActiveRecord::Migration[4.2]
  3. def up
  4. # return if it's a new setup
  5. return if !Setting.exists?(name: 'system_init_done')
  6. # load existing LDAP config
  7. ldap_config = Setting.get('ldap_config')
  8. # exit early if no config is present
  9. return if ldap_config.blank?
  10. return if ldap_config['group_role_map'].blank?
  11. # loop over group role mapping and check
  12. # if we need to migrate to new array structure
  13. ldap_config['group_role_map'].each do |source, dest|
  14. next if dest.is_a?(Array)
  15. ldap_config['group_role_map'][source] = [dest]
  16. end
  17. # store updated
  18. Setting.set('ldap_config', ldap_config)
  19. end
  20. end