class Ucert::CitrixSharefileTracker
Class to handle Citrix Sharefile user account
Attributes
verbose[RW]
Class constant variables
Public Class Methods
new(params ={})
click to toggle source
Instance default variables
# File lib/ucert/citrix_sharefile_tracker.rb, line 21 def initialize (params ={}) @verbose=params.fetch(:verbose, false) # Citrix Sharefile user entitlement report generation instruction: # http://support.citrixonrow.com/en_US/ShareFile/all_files/SF070008 # Please raise a new 'Application Security Request' in the Mantis ticketing system, in order to obtain # the latest copy @sharefile_user_entitlement_report = File.dirname(__FILE__)+"/../../data/citrix_sharefile/ShareFile_Access_Report.xlsx" # Sharefile to AD user map file @file_sharefile_user_map = File.dirname(__FILE__)+"/../../data/citrix_sharefile/sharefile_user_map.txt" # Load user map from the local cacsh file @sharefile_2_ad_user=load_known_user_map_from_file(@file_sharefile_user_map) # Load the user entitlement instance variable from the user report @sharefile_user_entitlement=parse_sharefile_user_entitlement_report(@sharefile_user_entitlement_report) # Procedure to add DN foreign key to the @sharefile_user_entitlement, by performing the AD search insert_dn # Save the user map to local cache file save! end
Public Instance Methods
db_search_by_dn(dn)
click to toggle source
Search user entitlement record by AD DN
# File lib/ucert/citrix_sharefile_tracker.rb, line 181 def db_search_by_dn (dn) begin puts "Perform search on the user entitlement records by AD DN: #{dn}" if @verbose @sharefile_user_entitlement.each do |key, val| return val if @sharefile_user_entitlement[key]['DN'].eql? dn end return nil rescue => ee puts "Exception on method #{__method__}: #{ee}" end end
Also aliased as: search_by_dn
dn_2_index(dn)
click to toggle source
Retrieve the user index from the @sharefile_user_entitlement data structure
# File lib/ucert/citrix_sharefile_tracker.rb, line 93 def dn_2_index (dn) begin (1..@sharefile_user_entitlement.count).map do |index| return index if @sharefile_user_entitlement[index]["DN"]==dn end rescue => ee puts "Exception on method #{__method__}: #{ee}" end end
Private Instance Methods
insert_dn()
click to toggle source
Procedures to add additonal field 'dn' into the @sharefile_user_entitlement data structure, by person the AD search
# File lib/ucert/citrix_sharefile_tracker.rb, line 104 def insert_dn begin tracker = Ucert::AdTracker.new(:verbose=>false) @sharefile_user_entitlement.each do |index, record| puts "\n\nPerform DN lookup for record: #{record}" if @verbose key1 = index key2 = record['FirstName'] + ":" + record['LastName'] if record['FirstName'] && record['LastName'] key3 = record['FirstName'] if record['FirstName'] my_key = index.upcase puts "Perform 1st order search from the local cache: #{my_key}" if @verbose if @sharefile_2_ad_user.key?(my_key) dn=@sharefile_2_ad_user[my_key] # additional logic to update the existing DN record unless tracker.ad_person_records.key?(dn) dn = update_dn(tracker,dn) end puts "Found in the local cache file: #{dn}" if @verbose else if dn.nil? and !key1.nil? puts "Perform 2nd order search only if the 1st one fail, by using: #{key1}" if @verbose dn = tracker.ad_search_by_text(key1, "person") end if dn.nil? and !key2.nil? puts "Perform 3rd order search only if the last fail, by using: #{key2}" if @verbose dn = tracker.ad_search_by_text(key2, "person") end if dn.nil? and !key3.nil? puts "Perform 4th order search only if the last fail, by using: #{key3}" if @verbose dn = tracker.ad_search_by_text(key3, "person") end end @sharefile_user_entitlement[index]['DN'] = dn end tracker=nil rescue => ee puts "Exception on method #{__method__}: #{ee}" end end
print_user_entitlement()
click to toggle source
Print out the user entitlement table in plain text, to be imported into database
# File lib/ucert/citrix_sharefile_tracker.rb, line 144 def print_user_entitlement begin puts "user Entitlement Report in Plain-text Format" if @verbose @sharefile_user_entitlement.first.each {|k,v| print k,"|"} if @verbose puts if @verbose @sharefile_user_entitlement.values.map do |rec| rec.each {|k,v| print v,"|"} puts end rescue => ee puts "Exception on method #{__method__}: #{ee}" end end
Also aliased as: print_user