Sha256: b60af6f686a78adb6d994d09ad224168ab822c9f46443ca5359a7fa961e7d2d8
Contents?: true
Size: 910 Bytes
Versions: 12
Compression:
Stored size: 910 Bytes
Contents
#!/usr/bin/env ruby require 'cratus' include Cratus LDAP.connect # Read in arguments group_mapping_arg = ARGV[0] raise 'Missing Group Mapping Argument!' unless group_mapping_arg group_mapping_file = File.expand_path(group_mapping_arg) raise "Invalid Group Mapping File #{group_mapping_file}" unless File.readable?(group_mapping_file) # Load the YAML file(s) for mapping permissions group_permissions = YAML.load_file(group_mapping_file) # Gather group memberships and permissions @results = {} # stash all the results here... might get really big User.all.sort.each do |user| key = user.username.to_s user_groups = user.member_of.map { |g| g.name.to_s } @results[key] = { 'groups' => {} } user_groups.sort.each do |ugroup| group_perm_set = group_permissions[ugroup] ? group_permissions[ugroup].sort : [] @results[key]['groups'][ugroup] = group_perm_set end end puts @results.to_yaml
Version data entries
12 entries across 12 versions & 1 rubygems