Sunday, April 25, 2021

Rule - Get the Entitlement which is requestable

 import sailpoint.object.QueryOptions;
import sailpoint.object.Filter;
import sailpoint.object.ManagedAttribute;
import sailpoint.object.Identity;
import sailpoint.api.ObjectUtil;
import java.util.*;
 
 List entitlements = context.getObjects(ManagedAttribute.class);
 log.debug("List of Entitlements: ");
 for (ManagedAttribute ent : entitlements){
 log.debug("getValue(): " +ent.getValue());
 }
  
 // Entitlements which are requestable
 QueryOptions qo = new QueryOptions();
 qo.addFilter(Filter.eq("requestable", (boolean) true));
 List reqEntitlements = context.getObjects(ManagedAttribute.class, qo);
 log.debug("List of Requestable Entitlements: ");
  for (ManagedAttribute ent : reqEntitlements){
 log.debug("getValue(): " +ent.getValue());
 }
 
 log.debug("\nTotal No. of Entitlements: "+entitlements.size());
 log.debug("\nTotal No. of Requestable Entitlements: "+reqEntitlements.size());


Comment below if you find this post helpful.

Rule - Get the Audit events who's action is Login

import sailpoint.object.QueryOptions;
import sailpoint.object.Filter;
import sailpoint.object.AuditEvent;

 ArrayList auditNames = new ArrayList();
 Filter loginFilter = Filter.eq("action", "login");
 List AuditList = context.getObjects(AuditEvent.class,new QueryOptions().addFilter(loginFilter));
    log.debug("\nAudit List"+AuditList);

 for (AuditEvent auditName : AuditList) {  
  log.debug(auditName.getName());
  auditNames.add(auditName.getName());
}


Comment below if you find this post helpful.

Rule - Get identities modified below 10 days from current date

import sailpoint.object.QueryOptions;
import sailpoint.object.Filter;
import sailpoint.object.Identity;
import sailpoint.api.ObjectUtil;
import java.util.*;

QueryOptions qo = new QueryOptions();
Calendar currentDate = Calendar.getInstance();
System.out.println("Current Date: " +currentDate); 
Date currentTime = currentDate.getTime();
System.out.println("Current Time: " +currentTime); 
currentDate.add(currentDate.DATE, -10); 

Date startDate = currentDate.getTime();
System.out.println("Start Time: " +startDate); 

Filter dateCondition = Filter.and(Filter.le("modified",currentTime), Filter.ge("modified",startDate));
qo.addFilter(dateCondition);
log.debug("============ Query ===========" +qo);

List identityObjectList = context.getObjects(Identity.class, qo);
List identityNames = ObjectUtil.getObjectNames(identityObjectList);
log.debug("List of identities modified: " +identityNames);

Comment below if you find this post helpful.

Rule - In Finance application, list out employees belongs to 'PAYROLL' department with privileged, inactive and service as 'FALSE'

 //In Finance application,list out employees belongs to 'PAYROLL' department with privileged 
//,inactive and service as 'FALSE'.Output should display identity details like first Name,LastName and email.

import sailpoint.object.QueryOptions;
import sailpoint.object.Filter;
import sailpoint.object.Identity;
import sailpoint.object.Link;
import sailpoint.object.Attributes;
 List linksList = new ArrayList();
 ArrayList accountInfo = new ArrayList();
 String privileged = null;
 String service = null;
 
 QueryOptions qo = new QueryOptions();
 Filter linkFilter = Filter.eq("links.application.name","Financials");
 Filter depFilter = Filter.eq("department","Accounting");
 qo.addFilter(Filter.and(linkFilter, depFilter));
 List identityList = context.getObjects(Identity.class, qo); 
 
 if(identityList != null){
  for(Identity identity : identityList){
 
  List links = identity.getLinks();
  if(links != null){
  for(Link link : links){
  String applicationName = link.getApplicationName();
 
  if(applicationName!= null && (applicationName.equalsIgnoreCase("Financials"))){
  Attributes attributes = link.getAttributes();
  if (attributes != null){
  if(attributes.getString("app2_privileged") != null && 
  (attributes.getString("app2_privileged").equalsIgnoreCase("false")) &&
  (attributes.getString("app2_service") != null) && 
  (attributes.getString("app2_service").equalsIgnoreCase("false")) ){
   
  privileged = attributes.getString("app2_privileged");
  service = attributes.getString("app2_service");
 
  accountInfo.add(identity.getName() + " :: " + identity.getFirstname() + " :: " + 
  " :: " + applicationName + " :: " + privileged + " :: "+ service);
  }
  }
  }
  } 
  }
  }
 
  log.debug( accountInfo);
 }

Comment below if you find this post helpful.

Thursday, April 22, 2021

Rule - List out distinct department name for all Identities

  import sailpoint.object.Identity;
 
HashSet depName = new HashSet();
 List identityList = context.getObjects(Identity.class);
 
 for(Identity identity : identityList){
  if(identity != null)
  depName.add(identity.getAttribute("department"));
 }
 log.error("Departments: " + depName);

Comment below if you find this post helpful.

Rule - Adding Identity to WorkGroup

 import sailpoint.object.QueryOptions;
import sailpoint.object.Filter;
import sailpoint.object.Identity;
  //get the workgroup
  Identity workGroupName = context.getObjectByName(Identity.class,"DemoWorkGroup");
  // get the identity
  Identity identityName = context.getObjectByName(Identity.class,"Aaron.Nichols");
  if(workGroupName!=null && identityName!=null ){
  identityName.add(workGroupName);
  context.saveObject(identityName);
  context.commitTransaction();
  }

Comment below if you find this post helpful.

Rule - Get the Identities who have "AcctsPayable" entitlement assigned

 import sailpoint.object.QueryOptions;
import sailpoint.object.Filter;
import sailpoint.object.IdentityEntitlement;
 
// Query the IdentityEntitlement object
QueryOptions qo = new QueryOptions();
qo.add(Filter.eq("value", "AcctsPayable"));
 
List entitlements = context.getObjects(IdentityEntitlement.class, qo);
log.error("List of Identities: ");
for (IdentityEntitlement ent : entitlements){
log.error(ent.getIdentity().getName());
}
log.error("No of identites having the Entitlements: " +entitlements.size());

Comment below if you find this post helpful.

Form AllowedValues rule to filter Identities with Active Regular Active Directory accounts and identity is active and correlated

 The rule type is AllowedValues. import org.apache.log4j.Level ; import org.apache.log4j.Logger ; import sailpoint.object.Filter ; import sa...