Name

global.CheckISCRunAsUser

Description

Notifies ISC users to set valid Run As user for AppSec Daily Data Management and PA AppSec Daily Data Collection jobs if existing Run As user for these jobs is invalid, locked or deleted.

Script

var CheckISCRunAsUser = Class.create();
CheckISCRunAsUser.prototype = {
constants: new ISCConstants(),
validate: function() {
  var errors = [];
  this._checkUser(this.constants.jobNames.APPSEC_DAILY_DATA_MANAGEMENT, true, 'admin');
  this._checkUser(this.constants.jobNames.APPSEC_DAILY_DATA_COLLECTION, false, '');

},
_checkUser: function(job_name, hasRole, role) {
  // validate run as user assigned to each job.

  var gr_job = GlideRecord(this.constants.tables.SYSAUTO);
  var gr_user = GlideRecord(this.constants.tables.SYS_USER);
  var gr_announcement = GlideRecord(this.constants.tables.ANNOUNCEMENT);


  gr_job.addEncodedQuery('name=' + job_name);
  gr_job.query();
  while (gr_job.next()) {
    if (hasRole) {
      gr_user.addEncodedQuery('sys_id=' + gr_job.run_as + '^roles=' + role + '^locked_out=false');
    } else {
      gr_user.addEncodedQuery('sys_id=' + gr_job.run_as + '^locked_out=false');
    }
    gr_user.query();
    if (!gr_user.next()) {
      if (hasRole && gr_announcement.get('name', 'Alert : Appsec Daily Data Management')) {
        gr_announcement.active = true;
        gr_announcement.update();
      } else if (!hasRole && gr_announcement.get('name', 'Alert : Appsec Daily Data Collection')) {
        gr_announcement.active = true;
        gr_announcement.update();
      }

    } else {

      if (hasRole && gr_announcement.get('name', 'Alert : Appsec Daily Data Management')) {
        gr_announcement.active = false;
        gr_announcement.update();

      } else if (!hasRole && gr_announcement.get('name', 'Alert : Appsec Daily Data Collection')) {
        gr_announcement.active = false;
        gr_announcement.update();

      }
    }
  }
},


type: 'CheckISCRunAsUser'
};

Sys ID

4fda5a0a531e0010628eddeeff7b1240

Offical Documentation

Official Docs: