Class: Ucert::FisEgiftsTracker
- Inherits:
-
Object
- Object
- Ucert::FisEgiftsTracker
- Includes:
- Utils
- Defined in:
- lib/ucert/fis_egifts_tracker.rb
Overview
Class to handle FIS eGifts user entitlement reprot
Instance Attribute Summary collapse
-
#egifts_2_ad_user ⇒ Object
readonly
Returns the value of attribute egifts_2_ad_user.
-
#egifts_group_entitlement ⇒ Object
readonly
Returns the value of attribute egifts_group_entitlement.
-
#egifts_user_account_function_report ⇒ Object
Class constant variables.
-
#egifts_user_entitlement ⇒ Object
readonly
Returns the value of attribute egifts_user_entitlement.
-
#file_user_map ⇒ Object
Class constant variables.
-
#verbose ⇒ Object
Class constant variables.
Instance Method Summary collapse
-
#egifts_search_by_dn(dn) ⇒ Object
(also: #search_by_dn)
Search user entitlement record by AD DN.
-
#initialize(params = {}) ⇒ FisEgiftsTracker
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.
-
#save_egifts_user_map!(file = @file_user_map) ⇒ Object
(also: #save!)
Save the egifts to AD user mapping relation into the cache file.
-
#user_name_2_record_num(name) ⇒ Object
egifts_user_entitlement table lookup, input is a user name, output is the corresponding user record 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 = {}) ⇒ FisEgiftsTracker
Instance default variables
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ucert/fis_egifts_tracker.rb', line 19 def initialize (params ={}) @verbose=params.fetch(:verbose, false) # egifts user entitlement report in xlxl format, generated by using super user from the portal: egifts web portal # -> REPORTS -> User Functions -> output type "Excel" -> open in Excel and resave it to 'XLXS' format @egifts_user_account_function_report = File.dirname(__FILE__)+"/../../data/fis_egifts/CHINA_MERCHANTS_BANK_-_USER_ACCOUNT_FUNCTION_REPORT.xlsx" # egifts to AD user map file @file_user_map = File.dirname(__FILE__)+"/../../data/fis_egifts/egifts_user_map.txt" # Load the user map file to an instance variable (for performance gain) @egifts_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' eGifts report @egifts_user_entitlement=parse_egifts_user_account_function_report(@egifts_user_account_function_report) # perform AD lookup for the corresponding DN record, add it into @egifts_user_entitlement hash insert_dn # save! end |
Instance Attribute Details
#egifts_2_ad_user ⇒ Object (readonly)
Returns the value of attribute egifts_2_ad_user.
16 17 18 |
# File 'lib/ucert/fis_egifts_tracker.rb', line 16 def egifts_2_ad_user @egifts_2_ad_user end |
#egifts_group_entitlement ⇒ Object (readonly)
Returns the value of attribute egifts_group_entitlement.
16 17 18 |
# File 'lib/ucert/fis_egifts_tracker.rb', line 16 def egifts_group_entitlement @egifts_group_entitlement end |
#egifts_user_account_function_report ⇒ Object
Class constant variables
15 16 17 |
# File 'lib/ucert/fis_egifts_tracker.rb', line 15 def egifts_user_account_function_report @egifts_user_account_function_report end |
#egifts_user_entitlement ⇒ Object (readonly)
Returns the value of attribute egifts_user_entitlement.
16 17 18 |
# File 'lib/ucert/fis_egifts_tracker.rb', line 16 def egifts_user_entitlement @egifts_user_entitlement end |
#file_user_map ⇒ Object
Class constant variables
15 16 17 |
# File 'lib/ucert/fis_egifts_tracker.rb', line 15 def file_user_map @file_user_map end |
#verbose ⇒ Object
Class constant variables
15 16 17 |
# File 'lib/ucert/fis_egifts_tracker.rb', line 15 def verbose @verbose end |
Instance Method Details
#egifts_search_by_dn(dn) ⇒ Object Also known as: search_by_dn
Search user entitlement record by AD DN
235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/ucert/fis_egifts_tracker.rb', line 235 def egifts_search_by_dn (dn) begin puts "Perform search on the user entitlement record by AD DN: #{dn}" if @verbose @egifts_user_entitlement.each do |key, val| return val if @egifts_user_entitlement[key]['DN'].eql? dn end return nil 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
201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/ucert/fis_egifts_tracker.rb', line 201 def print_user_entitlement begin puts "User Entitlement Report in Plain-text Format" if @verbose puts "User_Name Institution Branch Department First_Name Middle_Initial Last_Name Added_On Added_by Last_Login Last_Logout Password_Expiry Enable Deleted Verify_Status Profile Role Functions DN" if @verbose @egifts_user_entitlement.values.map do |record| puts "#{record['User_Name']}|#{record['Institution']}|#{record['Branch']}|#{record['Department']}|#{record['First_Name']}|#{record['Middle_Initial']}|#{record['Last_Name']}|#{record['Added_On']}|#{record['Added_by']}|#{record['Last_Login']}|#{record['Last_Logout']}|#{record['Password_Expiry']}|#{record['Enable']}|#{record['Deleted']}|#{record['Verify_Status']}|#{record['Profile']}|#{record['Role']}|#{record['Functions']}|#{record['DN']}" end rescue => ee puts "Exception on method #{__method__}: #{ee}" end end |
#save_egifts_user_map!(file = @file_user_map) ⇒ Object Also known as: save!
Save the egifts to AD user mapping relation into the cache file
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/ucert/fis_egifts_tracker.rb', line 215 def save_egifts_user_map!(file=@file_user_map) puts "Saving the known egifts to AD user mapping relationship to file: #{file} ..." if @verbose begin =Time.now f=File.open(file, 'w') f.write "# local egifts to AD user map file created by the #{self.class} class #{__method__} method at: #{}" @egifts_user_entitlement.values.map do |record| key = record['User_Name'].upcase + ':' + record['First_Name'].upcase value = record['DN'] f.write "\n#{key}|#{value}" end f.close puts "egifts to AD user map file is successfully saved to: #{file}" if @verbose rescue => ee puts "Exception on method #{__method__}: #{ee}" if @verbose end end |
#user_name_2_record_num(name) ⇒ Object
egifts_user_entitlement table lookup, input is a user name, output is the corresponding user record number
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/ucert/fis_egifts_tracker.rb', line 183 def user_name_2_record_num (name) begin raise "Invalid user name: #{name}" if name.nil? or name.empty? puts "Perform record number lookup for user name: #{name}" if @verbose @egifts_user_entitlement.each do |key,val| next if val['User_Name'].nil? or val['User_Name'].empty? if val['User_Name'].upcase == name.upcase puts "Record number found: #{key}" if @verbose return key end end return nil rescue => ee puts "Exception on method #{__method__}: #{ee}" end end |