class Ucert::BloombergTracker

Class to handle Bloomberg user account IDs

Attributes

bloomberg_user_entitlement[R]
verbose[RW]

Class constant variables

Public Class Methods

new(params ={}) click to toggle source

Instance default variables

# File lib/ucert/bloomberg_tracker.rb, line 18
def initialize (params ={})

  @verbose=params.fetch(:verbose, false)
              # Abtain the latest SID report from Bloomberg Customer Center under the Billing tab
              # locate the latest invoice, click and download 'Current Subscription'
              @bloomberg_sid_report = File.dirname(__FILE__)+"/../../data/bloomberg/SID.csv"
              #
              # Load the group entitlement instance variable
              # Level 1 - Load the user entitlement by perform the AD lookup (workstation access)
              parse_bloomberg_ws_info
              # Level 2 - Parse the SID report in the CSV format
              #parse_bloomber_sid
      end

Public Instance Methods

bloomberg_search_by_dn(dn) click to toggle source

Search user entitlement record by AD DN

# File lib/ucert/bloomberg_tracker.rb, line 81
    def bloomberg_search_by_dn (dn)
            begin
  puts "Perform search on the user entitlement record by AD DN: #{dn}" if @verbose
  @bloomberg_user_entitlement.each do |key, val|
      return val if @bloomberg_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
print_user()
print_user_entitlement() click to toggle source

Print out the user entitlement table in plain text, to be imported into database

Also aliased as: print_user
search_by_dn(dn)

Private Instance Methods

parse_bloomberg_ws_info() click to toggle source

Parsing the Bloomberg user entitlement report in CSV format

# File lib/ucert/bloomberg_tracker.rb, line 33
        def parse_bloomberg_ws_info
#                       begin
                                puts "Parsing known AD objects in search of the current Bloomberg users" if @verbose
                                @bloomberg_user_entitlement=Hash.new
        user_record=0
        tracker=Ucert::AdTracker.new
                                tracker.ad_person_records.keys.map do |record|
          puts "Processing record #{record.inspect}" if @verbose
          wks=tracker.get_dn_attributes("person", record, "userWorkstations")
                                        if wks.join(',').downcase.include?('bloomberg')
                                                puts "Bloomberg terminal assignment found for user: #{record}" if @verbose
                                                user_record+=1
                                                @bloomberg_user_entitlement[user_record]=Hash.new unless @bloomberg_user_entitlement.key?(user_record)
                                                @bloomberg_user_entitlement[user_record]['DN']=record
                                                @bloomberg_user_entitlement[user_record]['email']=tracker.get_dn_attribute("person",record,"mail")
                                                @bloomberg_user_entitlement[user_record]['CN']=tracker.extract_first_cn(record)
                                                @bloomberg_user_entitlement[user_record]['department']=tracker.get_dn_attribute("person",record,"department")
                                                @bloomberg_user_entitlement[user_record]['terminals']=Array.new unless @bloomberg_user_entitlement[user_record].key?('terminals')
                                                wks.join(',').split(',').map do |x|
                                                        @bloomberg_user_entitlement[user_record]['terminals'].push(x.strip) if x.downcase.include?('bloomberg')
                                                end
                                        end
                          end
                                tracker=nil
#      rescue => ee
#                               puts "Exception on method #{__method__}: #{ee}"
#                       end
        end