Module: Tapjoy::LDAP::Audit

Defined in:
lib/tapjoy/ldap/audit.rb,
lib/tapjoy/ldap/audit/by_user.rb,
lib/tapjoy/ldap/audit/by_group.rb

Defined Under Namespace

Classes: ByGroup, ByUser

Constant Summary collapse

SUB_COMMANDS =
%w(by_user by_group raw)

Class Method Summary collapse

Class Method Details

.by_groupObject



27
28
29
30
# File 'lib/tapjoy/ldap/audit.rb', line 27

def by_group
  audit = Tapjoy::LDAP::Audit::ByGroup.new
  audit.by_group
end

.by_userObject



32
33
34
35
# File 'lib/tapjoy/ldap/audit.rb', line 32

def by_user
  audit = Tapjoy::LDAP::Audit::ByUser.new
  audit.by_user
end

.commandsObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/tapjoy/ldap/audit.rb', line 9

def commands
  Trollop::options do
    usage 'user [SUB_COMMAND] [options]'
    synopsis "\nThis object is used for auditing LDAP permissions\nAvailable subcommands are: #{SUB_COMMANDS}"

    stop_on SUB_COMMANDS
  end

  cmd = ARGV.shift

  case cmd
  when 'by_user', 'by_group', 'raw'
    send(cmd) # call method with respective name
  else
    raise Tapjoy::LDAP::InvalidArgument
  end
end

.get_groups_with_membershipObject

Get hash of groups with list of members of each group



42
43
44
45
46
47
# File 'lib/tapjoy/ldap/audit.rb', line 42

def get_groups_with_membership
  filter = Net::LDAP::Filter.eq('objectclass', 'posixGroup')
  attributes = %w(cn memberUid)

  results = Tapjoy::LDAP::client.search(attributes, filter)
end

Clean output of hashes



51
52
53
54
55
56
57
58
59
# File 'lib/tapjoy/ldap/audit.rb', line 51

def print_hash(header_string, object_hash)
  puts header_string
  puts "=" * header_string.length
  object_hash.each_pair do |key, values|
    next if values.empty?
    puts "- #{key}"
    values.each { |value| puts "  - #{value}" }
  end
end

.rawObject



37
38
39
# File 'lib/tapjoy/ldap/audit.rb', line 37

def raw
  puts Tapjoy::LDAP::client.search.inspect
end