Class: Ucert::VpnTracker
- Inherits:
-
Object
- Object
- Ucert::VpnTracker
- Includes:
- Utils
- Defined in:
- lib/ucert/vpn_tracker.rb
Overview
Class to handle VPN user account IDs
Instance Attribute Summary collapse
-
#verbose ⇒ Object
Class constant variables.
-
#vpn_user_entitlement ⇒ Object
readonly
Returns the value of attribute vpn_user_entitlement.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ VpnTracker
constructor
Instance default variables.
-
#print_user_entitlement ⇒ Object
(also: #print_user)
Print out the user entitlement table in plain text, to be imported into database.
-
#vpn_search_by_dn(dn) ⇒ Object
(also: #search_by_dn)
Search user entitlement record by AD DN.
Methods included from Utils
#file_2_list, #is_fqdn?, #is_ip?, #is_url?, #list_2_file, #load_known_user_map_from_file, #nslookup, #search_ad, #update_dn
Constructor Details
#initialize(params = {}) ⇒ VpnTracker
Instance default variables
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ucert/vpn_tracker.rb', line 18 def initialize (params ={}) @verbose=params.fetch(:verbose, false) # VPN users are defined by assigning AD user into 3 different containers in CMBNY domain controller # Refer to the screenshot for further details # # # Load the group entitlement instance variable @vpn_class={"CN=Class1VPN,CN=Users,DC=ny,DC=cmbchina,DC=com"=>"class_1", "CN=Class2VPN,CN=Users,DC=ny,DC=cmbchina,DC=com"=>"class_2", "CN=Class3VPN,CN=Users,DC=ny,DC=cmbchina,DC=com"=>"class_3"} # Load the user entitlement instance variable by perform the AD lookup @vpn_user_entitlement=parse_vpn_user_info end |
Instance Attribute Details
#verbose ⇒ Object
Class constant variables
14 15 16 |
# File 'lib/ucert/vpn_tracker.rb', line 14 def verbose @verbose end |
#vpn_user_entitlement ⇒ Object (readonly)
Returns the value of attribute vpn_user_entitlement.
15 16 17 |
# File 'lib/ucert/vpn_tracker.rb', line 15 def vpn_user_entitlement @vpn_user_entitlement end |
Instance Method Details
#print_user_entitlement ⇒ Object Also known as: print_user
Print out the user entitlement table in plain text, to be imported into database
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/ucert/vpn_tracker.rb', line 61 def print_user_entitlement begin puts "VPN User Entitlement Report in Plain-text Format" if @verbose @vpn_user_entitlement[1].keys.map {|x| print x,"|"} if @verbose puts if @verbose @vpn_user_entitlement.values.each do |record| record.values.map {|y| print y,"|"} puts end puts rescue => ee puts "Exception on method #{__method__}: #{ee}" end end |
#vpn_search_by_dn(dn) ⇒ Object Also known as: search_by_dn
Search user entitlement record by AD DN
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/ucert/vpn_tracker.rb', line 79 def vpn_search_by_dn (dn) begin puts "Perform search on the user entitlement record by AD DN: #{dn}" if @verbose @vpn_user_entitlement.each do |key, val| return val if @vpn_user_entitlement[key]['DN'].eql? dn end return nil rescue => ee puts "Exception on method #{__method__}: #{ee}" end end |