Class: Ucert::T24Tracker
- Inherits:
-
Object
- Object
- Ucert::T24Tracker
- Includes:
- Utils
- Defined in:
- lib/ucert/t24_tracker.rb
Overview
Class to handle T24 user account IDs
Instance Attribute Summary collapse
-
#file_user_map ⇒ Object
Class constant variables.
-
#t24_2_ad_user ⇒ Object
readonly
Returns the value of attribute t24_2_ad_user.
-
#t24_group_entitlement ⇒ Object
readonly
Returns the value of attribute t24_group_entitlement.
-
#t24_group_entitlement_report ⇒ Object
Class constant variables.
-
#t24_user_entitlement ⇒ Object
readonly
Returns the value of attribute t24_user_entitlement.
-
#t24_user_entitlement_report ⇒ Object
Class constant variables.
-
#verbose ⇒ Object
Class constant variables.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ T24Tracker
constructor
Instance default variables.
-
#print_group_entitlement ⇒ Object
(also: #print_group)
Print out the group entitlement table in plain text, to be imported into database.
-
#print_user_entitlement ⇒ Object
(also: #print_user)
Print out the user entitlement table in plain text, to be imported into database.
-
#save_t24_user_map!(file = @file_user_map) ⇒ Object
(also: #save!)
Save the T24 to AD user mapping relation into the cache file.
-
#t24_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 = {}) ⇒ T24Tracker
Instance default variables
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ucert/t24_tracker.rb', line 19 def initialize (params ={}) @verbose=params.fetch(:verbose, false) # T24 user entitlement report in CSV format, generated by T24 web portal -> Tools -> MB Admin Menu -> # Business Tools -> Security management system -> System Users Managment -> # List of System User Info -> Find -> Save As CSV @t24_user_entitlement_report = File.dirname(__FILE__)+"/../../data/t24/T24_User_Rpt.csv" @t24_user_entitlement_xml_report = File.dirname(__FILE__)+"/../../data/t24/t24_usr.xml" # T24 group entitlement report in xml format, generated by T24 web portal -> Tools -> MB Admin Menu -> # Business Tools -> Security management system -> System Users Managment -> # List of User SMS Group Info -> Find -> Save As CSV @t24_group_entitlement_report = File.dirname(__FILE__)+"/../../data/t24/T24_Grp_Rpt.csv" @t24_group_entitlement_xml_report = File.dirname(__FILE__)+"/../../data/t24/t24_grp.xml" # T24 to AD user map file @file_user_map = File.dirname(__FILE__)+"/../../data/t24/t24_user_map.txt" # Load the user map file to an instance variable (for performance gain) @t24_2_ad_user=load_known_user_map_from_file(@file_user_map) # Load the user entitlement instance variable from the native T24 user entitlement report #@t24_user_entitlement=parse_t24_user_report(@t24_user_entitlement_report) @t24_user_entitlement=parse_t24_user_xml_report(@t24_user_entitlement_xml_report) # Insert DN field into the user entitlement data structure insert_dn # Load the group entitlement instance variable from the native T24 group entitlement report #@t24_group_entitlement=parse_t24_group_report(@t24_group_entitlement_report) @t24_group_entitlement=parse_t24_group_xml_report(@t24_group_entitlement_xml_report) save! end |
Instance Attribute Details
#file_user_map ⇒ Object
Class constant variables
15 16 17 |
# File 'lib/ucert/t24_tracker.rb', line 15 def file_user_map @file_user_map end |
#t24_2_ad_user ⇒ Object (readonly)
Returns the value of attribute t24_2_ad_user.
16 17 18 |
# File 'lib/ucert/t24_tracker.rb', line 16 def t24_2_ad_user @t24_2_ad_user end |
#t24_group_entitlement ⇒ Object (readonly)
Returns the value of attribute t24_group_entitlement.
16 17 18 |
# File 'lib/ucert/t24_tracker.rb', line 16 def t24_group_entitlement @t24_group_entitlement end |
#t24_group_entitlement_report ⇒ Object
Class constant variables
15 16 17 |
# File 'lib/ucert/t24_tracker.rb', line 15 def t24_group_entitlement_report @t24_group_entitlement_report end |
#t24_user_entitlement ⇒ Object (readonly)
Returns the value of attribute t24_user_entitlement.
16 17 18 |
# File 'lib/ucert/t24_tracker.rb', line 16 def t24_user_entitlement @t24_user_entitlement end |
#t24_user_entitlement_report ⇒ Object
Class constant variables
15 16 17 |
# File 'lib/ucert/t24_tracker.rb', line 15 def t24_user_entitlement_report @t24_user_entitlement_report end |
#verbose ⇒ Object
Class constant variables
15 16 17 |
# File 'lib/ucert/t24_tracker.rb', line 15 def verbose @verbose end |
Instance Method Details
#print_group_entitlement ⇒ Object Also known as: print_group
Print out the group entitlement table in plain text, to be imported into database
293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/ucert/t24_tracker.rb', line 293 def print_group_entitlement begin puts "Group Entitlement Report in Plain-text Format" if @verbose puts "@ID | DESCRIPTION | APPLICATION" if @verbose @t24_group_entitlement.values.map do |record| puts "#{record['ID']}|#{record['DESCRIPTION']}|#{record['APPLICATION']}"# "\t#{record['VERSION']}\t#{record['FUNCTION']}" end rescue => ee puts "Exception on method #{__method__}: #{ee}" end end |
#print_user_entitlement ⇒ Object Also known as: print_user
Print out the user entitlement table in plain text, to be imported into database
279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/ucert/t24_tracker.rb', line 279 def print_user_entitlement begin puts "User Entitlement Report in Plain-text Format" if @verbose puts "@ID USER.NAME APPLICATION GROUP START.DATE.PROFILE END.DATE.PROFILE DN" if @verbose @t24_user_entitlement.values.map do |record| puts "#{record['ID']}|#{record['USER.NAME']}|#{record['APPLICATION']}|#{record['GROUP']}|#{record['START.DATE.PROFILE']}|#{record['END.DATE.PROFILE']}|#{record['DN']}" end rescue => ee puts "Exception on method #{__method__}: #{ee}" end end |
#save_t24_user_map!(file = @file_user_map) ⇒ Object Also known as: save!
Save the T24 to AD user mapping relation into the cache file
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
# File 'lib/ucert/t24_tracker.rb', line 307 def save_t24_user_map!(file=@file_user_map) puts "Saving the known T24 to AD user mapping relationship to file: #{file} ..." if @verbose begin =Time.now f=File.open(file, 'w') f.write "# local T24 to AD user map file created by the #{self.class} class #{__method__} method at: #{}" @t24_user_entitlement.values.map do |record| key = record['ID'].upcase + ':' + record['USER.NAME'].upcase value = record['DN'] f.write "\n#{key}|#{value}" end f.close puts "T24 to AD user map file is successfully saved to: #{file}" if @verbose rescue => ee puts "Exception on method #{__method__}: #{ee}" if @verbose end end |
#t24_search_by_dn(dn) ⇒ Object Also known as: search_by_dn
Search user entitlement record by AD DN
327 328 329 330 331 332 333 334 335 336 337 |
# File 'lib/ucert/t24_tracker.rb', line 327 def t24_search_by_dn (dn) begin puts "Perform search on the user entitlement record by AD DN: #{dn}" if @verbose @t24_user_entitlement.each do |key, val| return val if @t24_user_entitlement[key]['DN'].eql? dn end return nil rescue => ee puts "Exception on method #{__method__}: #{ee}" end end |