class Ucert::Check21Tracker

Class to handle Check21 user account IDs

Attributes

check21_user_entitlement[R]
verbose[RW]

Class constant variables

Public Class Methods

new(params ={}) click to toggle source

Instance default variables

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

  @verbose=params.fetch(:verbose, false)
  # Check21 user list are defined by allocating "OA-Check21" machine into their AD profile in the domain controller
  # Refer to the screenshot for further details
              #
              #
              # Load the group entitlement instance variable
  @check21_access={"userWorkstations"=>"OA-CHECK21"}
              # Load the user entitlement instance variable by performing the AD lookup
              @check21_user_entitlement=parse_check21_user_info
      end

Public Instance Methods

check21_search_by_dn(dn) click to toggle source

Search user entitlement record by AD DN

# File lib/ucert/check21_tracker.rb, line 80
    def check21_search_by_dn (dn)
            begin
  puts "Perform search on the user entitlement record by AD DN: #{dn}" if @verbose
  @check21_user_entitlement.each do |key, val|
      return val if @check21_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_check21_user_info() click to toggle source

Parsing the Check21 user entitlement report in CSV format

# File lib/ucert/check21_tracker.rb, line 32
  def parse_check21_user_info
                  begin
                          puts "Parsing known AD objects in search of the current Check21 users" if @verbose
                          check21_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
    computer_accesss=tracker.get_dn_attribute("person", record, "userWorkstations")
                                  next if computer_accesss.nil?
                                  c_access = computer_accesss.upcase.split(',')
    my_class = c_access & @check21_access.values
                                  if my_class.size >0
                                          puts "Check21 user found: #{record}" if @verbose
                                          user_record+=1
                                          check21_entitlement[user_record]=Hash.new unless check21_entitlement[user_record]
                                          check21_entitlement[user_record]['CN']=tracker.extract_first_cn(record)
                                          check21_entitlement[user_record]['department']=tracker.get_dn_attribute("person",record,"department")
                                          check21_entitlement[user_record]['sAMAccountName']=tracker.get_dn_attribute("person",record,"sAMAccountName")
                                          check21_entitlement[user_record]['DN']=record
                                  end
                    end
                          tracker=nil
  return check21_entitlement
rescue => ee
                          puts "Exception on method #{__method__}: #{ee}"
                  end
  end