Class: Ucert::Sage100Tracker
- Inherits:
-
Object
- Object
- Ucert::Sage100Tracker
- Includes:
- Utils
- Defined in:
- lib/ucert/sage100_tracker.rb
Overview
Class to handle Sage 100 ERP user entitlement reprot
Instance Attribute Summary collapse
-
#file_user_map ⇒ Object
Class constant variables.
-
#sy_2_ad_user ⇒ Object
readonly
Returns the value of attribute sy_2_ad_user.
-
#sy_user_details_report ⇒ Object
Class constant variables.
-
#sy_user_entitlement ⇒ Object
readonly
Returns the value of attribute sy_user_entitlement.
-
#sy_user_role_details_report ⇒ Object
Class constant variables.
-
#verbose ⇒ Object
Class constant variables.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Sage100Tracker
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.
-
#sage100_search_by_dn(dn) ⇒ Object
(also: #search_by_dn)
Search user entitlement r_index by AD DN.
-
#user_name_2_index(name) ⇒ Object
sy_user_entitlement table lookup, input is “User Name”, output is the corresponding user r_index number.
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 = {}) ⇒ Sage100Tracker
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 46 47 48 |
# File 'lib/ucert/sage100_tracker.rb', line 19 def initialize (params ={}) @verbose=params.fetch(:verbose, false) # sage 100 user entitlement details report in xlsx format, generated by accessing Sage 100 under production environtment # Once logon, go to "Report -> User Report -> select "All", "Datat Only Export"; choose "Role and Preferences Details" then # press "Print" to open Export window. # Under "Export" menu, choose "Microsoft Excel Workbook Data-only" as Format, "Disk" as Destination, then press OK button to # generate and save the report; refer to the screenshot for details. # # Note 1/12/2015: # => I did not like the complexity of the XML generated automatically by the Crytal Report module. IMHO the Excel format # is a cleaner option. # => No need to parse the user role report as the information is already presetned in the user report above @sy_user_details_report = File.dirname(__FILE__)+"/../../data/sage100/SY_UserReport_RolePreferencesDetails.xlsx" # "Report -> User Report -> select "All", "Datat Only Export"; choose "Role and Task Permissions Details" then # press "Print" to open Export window. # Under "Export" menu, choose "Microsoft Excel Workbook Data-only" as Format, "Disk" as Destination, then press OK button to # generate and save the report; refer to the screenshot for details. @sy_role_details_report = File.dirname(__FILE__)+"/../../data/sage100/SY_UserReport_RoleTaskPermissionsDetails.xlsx" # sage100 to AD user map file @file_user_map = File.dirname(__FILE__)+"/../../data/sage100/sy_user_map.txt" # Load the user map file to an instance variable (for performance gain) @sy_2_ad_user=load_known_user_map_from_file(@file_user_map) # Load the user entitlement instance variable from the most complete 'User Accout Function' Sage report @sy_user_entitlement=parse_sy_user_role_preferences_detail_report (@sy_user_details_report) # Load the user role task permissions detail report (@sy_role_details_report) # Procedure to perform Sage to AD user matching, insert AD DN into @sy_user_entitlement data structure insert_dn save! end |
Instance Attribute Details
#file_user_map ⇒ Object
Class constant variables
15 16 17 |
# File 'lib/ucert/sage100_tracker.rb', line 15 def file_user_map @file_user_map end |
#sy_2_ad_user ⇒ Object (readonly)
Returns the value of attribute sy_2_ad_user.
16 17 18 |
# File 'lib/ucert/sage100_tracker.rb', line 16 def sy_2_ad_user @sy_2_ad_user end |
#sy_user_details_report ⇒ Object
Class constant variables
15 16 17 |
# File 'lib/ucert/sage100_tracker.rb', line 15 def sy_user_details_report @sy_user_details_report end |
#sy_user_entitlement ⇒ Object (readonly)
Returns the value of attribute sy_user_entitlement.
16 17 18 |
# File 'lib/ucert/sage100_tracker.rb', line 16 def sy_user_entitlement @sy_user_entitlement end |
#sy_user_role_details_report ⇒ Object
Class constant variables
15 16 17 |
# File 'lib/ucert/sage100_tracker.rb', line 15 def sy_user_role_details_report @sy_user_role_details_report end |
#verbose ⇒ Object
Class constant variables
15 16 17 |
# File 'lib/ucert/sage100_tracker.rb', line 15 def verbose @verbose 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
307 308 309 310 311 312 313 314 315 316 317 |
# File 'lib/ucert/sage100_tracker.rb', line 307 def print_user_entitlement begin puts "User Entitlement Report in Plain-text Format" if @verbose puts "User Logon|First Name|Last Name|Active|User Code|Customization Group|Expires|User Account Locked|E-mail|Preferences|Role|Scope|DN" if @verbose @sy_user_entitlement.values.map do |r_index| puts "#{r_index['User Logon']}|#{r_index['First Name']}|#{r_index['Last Name']}|#{r_index['Active']}|#{r_index['User Code']}|#{r_index['Customization Group']}|#{r_index['Expires']}|#{r_index['User Account Locked']}|#{r_index['E-mail']}|#{r_index['Preferences']}|#{r_index['Permissions']}|#{r_index['Role']}|#{r_index['Scope']}|#{r_index['DN']}" end rescue => ee puts "Exception on method #{__method__}: #{ee}" end end |
#sage100_search_by_dn(dn) ⇒ Object Also known as: search_by_dn
Search user entitlement r_index by AD DN
341 342 343 344 345 346 347 348 349 350 351 |
# File 'lib/ucert/sage100_tracker.rb', line 341 def sage100_search_by_dn (dn) begin puts "Perform search on the user entitlement r_index by AD DN: #{dn}" if @verbose @sy_user_entitlement.each do |key, val| return val if @sy_user_entitlement[key]['DN'].eql? dn end return nil rescue => ee puts "Exception on method #{__method__}: #{ee}" end end |
#user_name_2_index(name) ⇒ Object
sy_user_entitlement table lookup, input is “User Name”, output is the corresponding user r_index number
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/ucert/sage100_tracker.rb', line 289 def user_name_2_index (name) begin raise "Invalid user name: #{name}" if name.nil? or name.empty? puts "Perform Record number lookup for user name: #{name}" if @verbose @sy_user_entitlement.each do |key,val| next if val['User Logon'].nil? or val['User Logon'].empty? if val['User Logon'].upcase == name.upcase puts "User record number found: #{key}" if @verbose return key end end return nil rescue => ee puts "Exception on method #{__method__}: #{ee}" end end |