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
Constant Summary collapse
- SUB_COMMANDS =
%w(by_user by_group raw)
Class Method Summary collapse
- .by_group ⇒ Object
- .by_user ⇒ Object
- .commands ⇒ Object
-
.get_groups_with_membership ⇒ Object
Get hash of groups with list of members of each group.
-
.print_hash(header_string, object_hash) ⇒ Object
Clean output of hashes.
- .raw ⇒ Object
Class Method Details
.by_group ⇒ Object
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_user ⇒ Object
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 |
.commands ⇒ Object
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. 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_membership ⇒ Object
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 |
.print_hash(header_string, object_hash) ⇒ Object
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 |