Showing posts with label Rules_Scripts_APIs. Show all posts
Showing posts with label Rules_Scripts_APIs. Show all posts

Monday, November 10, 2025

IdentityModel

  <Step action="call:getIdentityModel" name="Initialize" posX="15" posY="115" resultVariable="identityModel">

    <Description>

       Initialize the data for the identity that we are creating.

    </Description>

    <Transition to="xyz"/>

 </Step>

 

  <Script>

      <Source>

        String name = (String)identityModel.get("name");

        if (name != null) {

          name = name.trim();

        }

        return name;

      </Source>

  </Script>

Tuesday, November 4, 2025

Single Identity Refresh

import java.util.HashMap;

import java.util.Map;

import sailpoint.api.Identitizer;

import sailpoint.api.ObjectUtil;

import sailpoint.api.PersistenceManager;

import sailpoint.api.SailPointContext;

import sailpoint.object.Attributes;

import sailpoint.object.Identity;

import sailpoint.tools.GeneralException;


public class SingleIdentityRefresh {

static SailPointContext context = null;

public static String singleIdentityRefresh(String name) {

try {

// pass the refresh task attributes

Map map = new HashMap();

map.put("", true);

map.put("", true);

map.put("", true);

map.put("", true);

Attributes attributes = new Attributes(map);

Identity identity = ObjectUtil.lockObject(context, Identity.class, null, name, PersistenceManager.LOCK_TYPE_TRANSACTION);

Identitizer identitizer = new Identitizer(context, attributes);

identitizer.refresh(identity);

context.saveObject(identity);

context.commitTransaction();

} catch (GeneralException e) {

System.out.println("GeneralException : " + e.getMessage());

}

return "success";

}

public static void main(String[] args) {

singleIdentityRefresh("Aaron.Nicols");

}

}

Thursday, October 23, 2025

Dangling Entitlement Report

 import java.util.ArrayList;

  import java.util.Iterator;

  import java.util.List;

  import java.util.regex.Matcher;

  import java.util.regex.Pattern;

  import org.apache.commons.logging.Log;

  import org.apache.commons.logging.LogFactory;

  import sailpoint.api.IdentityService;

  import sailpoint.api.SailPointContext;

  import sailpoint.object.Application;

  import sailpoint.object.EmailFileAttachment;

  import sailpoint.object.EmailOptions;

  import sailpoint.object.EmailTemplate;

  import sailpoint.object.Filter;

  import sailpoint.object.Identity;

  import sailpoint.object.IdentityEntitlement;

  import sailpoint.object.Link;

  import sailpoint.object.QueryOptions;

  import sailpoint.tools.GeneralException;

  import sailpoint.tools.Util;


  public static boolean isValidUser(String name) {

    String regex = "^-?\\d+$";

    Pattern pattern = Pattern.compile(regex);

    Matcher matcher = pattern.matcher(name);

    return matcher.matches();

  }


  boolean flag = false;

  String name = null;

  String entitlement = null;

  List adLinks = null;

  List ticket = null;

  Identity identity = null;

  Application adApp = null;

  IdentityService adIdentityService = null;

  Iterator iterator = null;


  try {

    adLinks = new ArrayList();

    ticket = new ArrayList();

    ticket.add("name,Entitlement");


    adApp = context.getObjectByName(Application.class, "AD");

    if (adApp == null) {

      logger.error("AD application not found");

      return "AD application not found";

    }


    Filter filter = Filter.and(Filter.eq("type", "Entitlement"), Filter.eq("aggregationState", "Connected"), Filter.eq("application", adApp));

    QueryOptions qo = new QueryOptions();

    qo.addFilter(filter);


    iterator = context.search(IdentityEntitlement.class, qo);


    while (iterator.hasNext()) {

      IdentityEntitlement ide = iterator.next();


      if ((ide.getSourceAssignableRoles() == null @or ide.getSourceAssignableRoles().isEmpty()) @and ide.getIdentity() != null @and ide.getIdentity().isCorrelated()) {


        identity = ide.getIdentity();

        name = identity.getName();

        flag = isValidUser(name);


        if (flag) {

          adIdentityService = new IdentityService(context);

          adLinks = adIdentityService.getLinks(identity, adApp);


          if (adLinks != null @and !adLinks.isEmpty()) {

            for (Link link : adLinks) {

              if (link.getAttribute("serviceAccount") == null) {

                

                entitlement = ide.getValue().toString();

                ticket.add("\n" + name + "," + entitlement);

              }

            }

          }

        }

      }

    }


    EmailOptions emOptions = new EmailOptions();

    EmailTemplate snowTemplate = context.getObjectByName(EmailTemplate.class, "AD-Dang-ENT-TicketEmail");


    if (ticket != null @and !ticket.isEmpty()) {


      String tickerDetails = ticket.toString().replace("[","").replace("]","");

      byte[] ticketDetailsDataByte = tickerDetails.getBytes();

      EmailFileAttachment ticFileAttachment = new EmailFileAttachment("AD-Dangling-ENTS.csv", EmailFileAttachment.MimeType.MIME_CSV, ticketDetailsDataByte);


      emOptions.addAttachment(ticFileAttachment);

      emOptions.setVariable("createIncident", "##CREATEINCIDENT##");

      emOptions.setVariable("assignmentGroup", "Pedia-Enterprice");

      emOptions.setTo("admin@example.com");


      context.sendEmailNotification(snowTemplate, emOptions);


    }


  } catch (GeneralException e) {

    logger.error("GeneralException : "+e.getMessage());

  }

  finally {

    if (iterator != null) {

      Util.flushIterator(iterator);

    }

    if (adLinks != null) {

      adLinks.clear();

    }

    if (ticket != null) {

      ticket.clear();

    }

  }


Sunday, August 31, 2025

test31

<Source>

import sailpoint.object.ProvisioningPlan;

  import sailpoint.object.ProvisioningPlan.AccountRequest;

  import sailpoint.object.ProvisioningPlan.AttributeRequest;

  import sailpoint.connector.webservices.EndPoint;

  import sailpoint.tools.Util;

  import sailpoint.util.Listl

 

  

  log.error("***currentbody***"+  requestEndPoint.getBody().get("jsonBody")); 

  log.error("***requestEndPoint *** "+  requestEndPoint );

  log.error("***provisioningPlan *** "+  provisioningPlan );

 

  if (provisioningPlan != null @and requestEndPoint != null) {

    String nativeIdentity = plan.getNativeIdentity();

    log.error("Native Identity: " + nativeIdentity);

   List accountRequests = plan.getAccountRequests();

     log.error("accountRequests: " + accountRequests);

   if(accountRequests != null @and accountRequests.size() > 0){

    for (AccountRequest accountRequest : accountRequests) {

      AccountRequest.Operation op = accountRequest.getOperation();

      log.error("Operation: " + op);

      log.error("Account Native Identity: " + accountRequest.getNativeIdentity());

  

List attrRequests = accountRequest.getAttributeRequests();

log.error("attrRequests: " + attrRequests);

if(attrRequests != null @and attrRequests.size() > 0){

      for (AttributeRequest attrRequest : attrRequests) {

  

        String attrName = attrRequest.getName();

        Object attrValue = attrRequest.getValue();

 

 

        if (attrValue instanceof String) {

          log.error("It's a String");

        } else if (attrValue instanceof Integer) {

          log.error("It's an Integer");

        }

 

 

        log.error("Attribute: " + attrName + " | Value: " + attrValue);

 

        // Add 'role_Id' attribute if operation is Modify

        if (op == AccountRequest.Operation.Modify) {

          AttributeRequest attrGrpRequest = new AttributeRequest("role_Id", ProvisioningPlan.Operation.Set, attrValue);

          accountRequest.add(attrGrpRequest);

          log.error("Added role_Id attribute with value: " + attrValue);

        }

  

        if (op == AccountRequest.Operation.Create) {

          AttributeRequest attrGrpRequest = new AttributeRequest("role_Id", ProvisioningPlan.Operation.Set, attrValue);

          accountRequest.add(attrGrpRequest);

          log.error("Added role_Id attribute with value: " + attrValue);

        }

}

      }

  }

    }

  }

 

  log.error("Provisioning rule completed.");

  //return endPoint;

  </Source>

Wednesday, August 7, 2024

how to fetch IT roles based on entitlements in SailPoint IIQ?

import java.util.ArrayList;
import java.util.List;
import sailpoint.api.SailPointContext;
import sailpoint.object.Bundle;
import sailpoint.object.Filter;
import sailpoint.object.Profile;
import sailpoint.object.QueryOptions; 

String appName="Mighty";
String entitlementName = "DPA";
QueryOptions profileQo = new QueryOptions();
profileQo.addFilter(Filter.eq("application.name", appName));


  List bundles = new ArrayList();
  List profiles = context.getObjects(Profile.class, profileQo);

  if (profiles != null) {
    for (Object profileObj : profiles) {
      Profile p = (Profile) profileObj;
      List constraints = p.getConstraints();
      List filterList = null;
  
      if (constraints != null) {
        for (Object filter : constraints) {

          filterList = new ArrayList();
          if (filter instanceof sailpoint.object.Filter.LeafFilter) {
            sailpoint.object.Filter.LeafFilter f = (sailpoint.object.Filter.LeafFilter) filter;

            //Filter can have multiple values 
            Object value = f.getValue();

            if (value instanceof ArrayList) {

              ArrayList entitlements = new ArrayList();
              entitlements = (ArrayList) value;

              for (Object obj : entitlements) {
                if (obj.toString().equals(entitlementName)) {

                  Bundle bun = p.getBundle();
                  bundles.add(bun.getName());
                }

              }

            }

          }

        }

      }

    }

  }

  return bundles;

Friday, May 3, 2024

WorkflowLaunch

HashMap<String,Object> map = new HashMap<String,Object>();

        map.put("allowRequestsWithViolations","true");

        map.put("approvalMode","serial");

        map.put("approvalScheme","none"); // For auto approval 

        map.put("AppName",applicationName); //Target applcation name

        map.put("doRefresh","true");

        map.put("enableRetryRequest","false");

        map.put("fallbackApprover","spadmin");

        map.put("flow",requestType);

        map.put("foregroundProvisioning","true");

        map.put("identityDisplayName",identityName);

        map.put("identityName",identityName);

        map.put("identity",identity);

        map.put("notificationScheme","user,requester");

        map.put("optimisticProvisioning","true");

        map.put("plan",plan);

        map.put("policiesToCheck","");

        map.put("policyScheme","continue");

        map.put("policyViolations","");

        map.put("project","");

        map.put("requireViolationReviewComments","true");

        map.put("securityOfficerName","");

        map.put("sessionOwner","spadmin");

        map.put("source","LCM");

        map.put("trace","true");

        map.put("violationReviewDecision","");

        map.put("workItemComments","");


//Create WorkflowLaunch and set values

Workflow wf = (Workflow) context.getObjectByName(Workflow.class,"Mighty - LCM Provisioning");

WorkflowLaunch wflaunch = new WorkflowLaunch(); 

wflaunch.setWorkflowName(wf.getName());

 wflaunch.setWorkflowRef(wf.getName());

 wflaunch.setCaseName("customProvToDB");

 //Launch workflow for application provisioning

 wflaunch.setVariables(map);

 wflaunch.setWorkflow(wf);  

       

 //Create Workflower and launch workflow from WorkflowLaunch

 Workflower workflower = new Workflower(context);

 WorkflowLaunch launch = workflower.launch(wflaunch);

 String workFlowId = launch.getWorkflowCase().getId();

log.error("workFlowId: "+workFlowId); 

API's Syntax

SailPointContext context = SailPointFactory.getCurrentContext();

Identity identity = new  Identity();

Identity identity = context.getObjectByName(Identity.class, "Magnus"));

Bundle bundle = new Bundle();

WorkflowLaunch wflaunch = new WorkflowLaunch();

Workflower workflower = new Workflower(context);

Friday, February 9, 2024

Fetch Resource Object entitlements and validate against custom object.

 import java.util.List;

  import java.util.Map;

  import org.apache.commons.logging.Log;

  import sailpoint.api.SailPointContext;

  import sailpoint.object.Custom;

  import sailpoint.object.ResourceObject;

  import sailpoint.tools.GeneralException;


  ResourceObject object = null;

  ResourceObject resourceObject = null;

  Custom custom = null;

  Map tablueauMap = null;

  Map tablueauENTMap = null;

  List listENT = null;

  try {

    if (object != null) {

      if (object.getStringList("memberOf") != null && object.getStringList("memberOf").size() > 0

&& !object.getStringList("memberOf").isEmpty()) {      

         listENT = object.getStringList("memberOf");

        log.error("TABLEAU groups are : "+listENT);

        custom = context.getObjectByName(Custom.class, "Test Custom Object");

        if (custom != null) {

          tablueauMap = custom.getAttributes().getMap();

          if (tablueauMap.size() > 0 @and tablueauMap.get("TABLEAU") != null) {

            tablueauENTMap = (Map) tablueauMap.get("TABLEAU");

            resourceObject = new ResourceObject();

            for (String ent: listENT) {

              if (tablueauENTMap.containsValue(ent)) {

                resourceObject = object;

              }

            }

          } else {

            log.error("Custom Object doesn't contains TABLEAU ");

          } 

        }  else {

          log.error("Custom Object is null");

        } 

      } else {

        log.error("Resource Object doesn't contains groups and length is zero");

      }

    } else {

      log.error("ResourceObject is null");

    }

    return resourceObject;

  } catch (GeneralException e) {

    log.error("GeneralException : " + e.getMessage());

  }

==========================================================================

import java.util.List;

import java.util.Map;

import org.apache.commons.logging.Log;

import sailpoint.api.SailPointContext;

import sailpoint.object.Custom;

import sailpoint.object.ResourceObject;

import sailpoint.tools.GeneralException;


public class ResourceObjectTest {


static SailPointContext context = null;

static ResourceObject object = null;

static ResourceObject resourceObject = null;

static Log log = null;


public static void main(String[] args) {

Custom custom = null;

Map tablueauMap = null;

Map tablueauENTMap = null;

List listENT = null;

try {

if (object != null) {

if (object.getAttribute("memberOf") != null) {

listENT = (List) object.getAttribute("memberOf");

if (listENT.size() > 0) {

custom = context.getObjectByName(Custom.class, "");


if (custom != null) {

tablueauMap = custom.getAttributes().getMap();


if (tablueauMap.size() > 0 && tablueauMap.get("TABLEAU") != null) {

tablueauENTMap = (Map) tablueauMap.get("TABLEAU");


for (Object object1 : listENT) {

if (tablueauENTMap.containsValue(object1)) {

resourceObject = object;

}

}


}

}

}

} else {

log.error("Resource Object doesn't contains groups ");

}

} else {

log.error("ResourceObject is : " + object);

}

} catch (GeneralException e) {

log.error("GeneralException : " + e.getMessage());

}

}

}

Tuesday, January 30, 2024

FieldValue Rule

 <?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd">

<Rule language="beanshell" name="Mighty - App FieldValue Rule" type="FieldValue">

  <Description>This rule can generate a field value (eg - an account name) using data from the given Identity. If this rule is run in the context of a workflow step then the arguments passed into the step will also be available. Also, any field values that have been processed so far from the policy related to the Application/Role will be available.</Description>

  <Signature returnType="String">

    <Inputs>

      <Argument name="log">

        <Description>

          The log object is associated with the SailPointContext.

        </Description>

      </Argument>

      <Argument name="context">

        <Description>

          A sailpoint.api.SailPointContext object that can be used to query the database if necessary.

        </Description>

      </Argument>

      <Argument name="identity" type="Identity">

        <Description>

          The Identity object represents the user needing the field value.

        </Description>

      </Argument>

      <Argument name="link" type="Link">

        <Description>

          The sailpoint.object.Link that is being acted upon. If the link is not applicable,

          this value will be null.

        </Description>

      </Argument>

      <Argument name="group" type="ManagedAttribute">

        <Description>

          The sailpoint.object.ManagedAttribute that is being acted upon. If the managed attribute

          is not applicable, the value will be null.

        </Description>

      </Argument>

      <Argument name="project" type="ProvisioningProject">

        <Description>

          The provisioning project is being acted upon. If a provisioning project is not applicable,

          the value will be null.

        </Description>

      </Argument>

      <Argument name="accountRequest" type="ProvisioningPlan.AccountRequest">

        <Description>

          The account request. If an account request is not applicable, the value will be null.

        </Description>

      </Argument>

      <Argument name="objectRequest" type="ProvisioningPlan.ObjectRequest">

        <Description>

          The object request. If an object request is not applicable, the value will be null.

        </Description>

      </Argument>

      <Argument name="role" type="Bundle">

        <Description>

          The role with the template we are compiling. If the role is

          not applicable, the value will be null.

        </Description>

      </Argument>

      <Argument name="application" type="Application">

        <Description>

          The sailpont.object.Application with the template we are compiling. If the application

          is not applicable, the value will be null.

        </Description>

      </Argument>

      <Argument name="template" type="Template">

        <Description>

          The Template that contains this field.

        </Description>

      </Argument>

      <Argument name="field" type="Field">

        <Description>

          The current field is being computed.

        </Description>

      </Argument>

      <Argument name="current" type="Object">

        <Description>

          The current value corresponds to the identity or account attribute that the field represents.

          If no current value is set, this value will be null.

        </Description>

      </Argument>

      <Argument name="operation" type="ProvisioningPlan.Operation">

        <Description>

          The operation being performed.

        </Description>

      </Argument>

    </Inputs>

    <Returns>

      <Argument name="value">

        <Description>

          The string value is created.

        </Description>

      </Argument>

    </Returns>

  </Signature>

  <Source>

  import org.apache.commons.logging.Log;

  import org.apache.log4j.Logger;

  import sailpoint.api.SailPointContext;

  import sailpoint.object.Field; 

  import sailpoint.object.Identity;

  import sailpoint.tools.GeneralException;


  Logger logger = Logger.getLogger("Mighty.rule.FeildValueRule");

  boolean isDebugEnabled = logger.isDebugEnabled();

  Object returnValue = null;


  if (identity != null) {

    if (isDebugEnabled) {

      try {

        logger.debug("Identity to XML =======" + identity.toXml());

      } catch (GeneralException e) {

        logger.error("GeneralException: " + e.getMessage());

      }

    }

    String fieldName = field.getName();


    switch (fieldName) {

      case "userId":

      if (identity.getStringAttribute("userId") != null) {

        returnValue = identity.getStringAttribute("userId");

      } else {

        returnValue = "";

      }

      break;

      case "phoneNo":

      if (identity.getStringAttribute("phoneNo") != null) {

        returnValue = identity.getStringAttribute("phoneNo");

      } else {

        returnValue = "";

      }

      break;

      case "email":

      if (identity.getEmail() != null) {

        returnValue = identity.getEmail();

      } else {

        returnValue = "";

      }

      break;

      case "firstName":

      if (identity.getFirstname() != null) {

        returnValue = identity.getFirstname();

      } else {

        returnValue = "";

      }

      break;

      case "lastName":

      if (identity.getLastname() != null) {

        returnValue = identity.getLastname();

      } else {

        returnValue = "";

      }

      break;

      case "dept":

      if (identity.getStringAttribute("dept") != null) {

        returnValue = identity.getStringAttribute("dept");

      } else {

        returnValue = "";

      }

      break;

      case "company":

      if (identity.getStringAttribute("company") != null) {

        returnValue = identity.getStringAttribute("company");

      } else {

        returnValue = "";

      }

      break;

      case "status":

      if (identity.getStringAttribute("status") != null) {

        returnValue = identity.getStringAttribute("status");

      } else {

        returnValue = "";

      }

      break;

      default:

      logger.debug("Field is not matched...");

      break;

    }

    if (isDebugEnabled) {

      logger.debug("Returning field value = " + returnValue + "for field name " + fieldName);

    }

  } else {

    logger.debug("Identity is null");

    returnValue = "";

  }

  return returnValue;

  </Source>

</Rule>


Sunday, January 21, 2024

ReferencedRule

<ReferencedRules>

<Reference class='sailpoint.object.Rule' name='Mighty Rule Library'/>

</ReferencedRules>

Tuesday, January 16, 2024

Delete-AllAccounts-In-Applciation-Safely

 import java.util.List;

import sailpoint.api.SailPointContext;

import sailpoint.object.Filter;

import sailpoint.object.Identity;

import sailpoint.object.QueryOptions;

import java.util.List;

import sailpoint.api.Provisioner;

import sailpoint.api.SailPointContext;

import sailpoint.object.Identity;

import sailpoint.object.Link;

import sailpoint.object.ProvisioningPlan;

import sailpoint.object.ProvisioningProject;

import sailpoint.object.ProvisioningPlan.AccountRequest;


try {

ProvisioningPlan plan = new ProvisioningPlan();

List identityList = context.getObjects(Identity.class);

for (Identity identity : identityList) {

if (identity != null &amp;&amp; (!"prasad".equals(identity.getName())))

{

plan.setIdentity(identity);

List links = identity.getLinks();

if (links != null &amp;&amp; links.size() > 0) {

for (Link linkObj : links) {

if (linkObj != null &amp;&amp; "Mighty App".equals(linkObj.getApplicationName())) {

AccountRequest accountRequest = new AccountRequest();

accountRequest.setOperation(AccountRequest.Operation.Delete);

accountRequest.setNativeIdentity(linkObj.getNativeIdentity());

accountRequest.setApplication(linkObj.getApplicationName());

plan.add(accountRequest);

}

}

}

Provisioner provisioner = new Provisioner(context);

ProvisioningProject project = provisioner.compile(plan);

provisioner.execute(project);

}

}

} catch (Exception e) {

log.error("exception occurred at: "+e.getMessage());

}

Tuesday, January 2, 2024

Update Entitlement In Cataloge

import java.util.HashMap; import java.util.Map; import sailpoint.api.SailPointContext; import sailpoint.object.ManagedAttribute;

public class UpdateEntitlmentInCataloge { static SailPointContext context = null; public static void main(String[] args) { try { Map map = new HashMap(); map.put("en_US", "IAM Test group: Mighty"); ManagedAttribute managedAttribute = context.getObjectById(ManagedAttribute.class, "be19f8788ba61b15818ba16e5d0d03e4"); managedAttribute.setAttribute("description", "Updated description: Mighty"); managedAttribute.setDisplayName("IAMTest2"); managedAttribute.setValue("CN=IAMTest,OU=Standard,OU=Security,OU=Groups,DC=ls,DC=mightypedia,DC=com"); managedAttribute.setDescriptions(map); context.saveObject(managedAttribute); context.commitTransaction(); context.decache(managedAttribute); // return "Success"; } catch (Exception e) { log.error("Exception occurred : " + e.getMessage()); } } }

Get All Entitlements of User

 <?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd">

<Rule language="beanshell" name="Get-All-Entitlements-Of-User">

  <Signature returnType="String">

    <Inputs>

      <Argument name="log">

        <Description>

          The log object is associated with the SailPointContext.

        </Description>

      </Argument>

      <Argument name="context">

        <Description>

          A sailpoint.api.SailPointContext object that can be used to query the database if necessary.

        </Description>

      </Argument>

      <Argument name="link">

        <Description>

          The Link is being inspected.

        </Description>

      </Argument>

    </Inputs>

    <Returns>

      <Argument name="daysTillExpiration">

        <Description>

          The number of days before password expiration. If the number is negative then the password has expired, if the number is positive then a notification should be sent out, otherwise, a null value is returned indicating no notification is necessary.

        </Description>

      </Argument>

    </Returns>

  </Signature>

  <Source>

  import java.util.ArrayList;

  import java.util.Iterator;

  import java.util.List;

  import sailpoint.api.SailPointContext;

  import sailpoint.object.Application;

  import sailpoint.object.Attributes;

  import sailpoint.object.EntitlementGroup;

  import sailpoint.object.Identity;


  List finalList = new ArrayList();

  String userName = "beereddy";

  Identity identity = context.getObjectByName(Identity.class, userName);


  if(identity != null @and identity.getExceptions() != null){

    List entGrps = identity.getExceptions();


    if (entGrps != null @and !entGrps.isEmpty()) {

      Iterator egItr = entGrps.iterator();


      while (egItr.hasNext()) {

        EntitlementGroup entEg = (EntitlementGroup) egItr.next();

        if (entEg != null) {

          if (entEg.getAttributes() != null) {

            finalList.add(entEg.getAttributes().getMap().get("memberOf"));

          }

        }

      }

      return finalList;

    }

  }

  </Source>

</Rule>


Monday, December 25, 2023

Generate Email address

              import sailpoint.object.Filter;

              import sailpoint.object.Identity;

              import sailpoint.object.QueryOptions;

              import sailpoint.tools.GeneralException;

              import sailpoint.api.SailPointContext;


              int count = 0;

              String firstName = null;

              String lastName = null;

              String userName = null;

              String email = null;

              String domain = "@testMighty.com";

              if (identity != null) {

              if (identity.getFirstname() != null @and identity.getFirstname().equalsIgnoreCase("")

              @and identity.getLastname() != null @and identity.getLastname().equalsIgnoreCase("")) {

              firstName = identity.getFirstname();

              lastName = identity.getLastname();

              userName = firstName + "." + lastName;

              email = userName + domain;

              QueryOptions qo = new QueryOptions();

              Filter filter = Filter.ignoreCase(Filter.like("email", email, Filter.MatchMode.START));

              qo.addFilter(filter);          

              try {

              count = context.countObjects(Identity.class, qo);

              if (count != 0) {

              email = userName + count + domain;

              }

              return email;

              } catch (GeneralException e) {

              System.out.println("GeneralException : " + e.getMessage());

              }

              } else {

              System.out.println("Identity firstname is " + firstName);

              System.out.println("Identity lastname is " + lastName);

              }

              } else {

              System.out.println("Identity object is null");

              }

Thursday, October 12, 2023

AfterProvisioning Rule

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

import org.apache.commons.logging.Log;

import org.apache.commons.logging.LogFactory;

import sailpoint.api.SailPointContext;

import sailpoint.object.EmailOptions;

import sailpoint.object.EmailTemplate;

import sailpoint.object.Identity;

import sailpoint.object.ProvisioningPlan;

import sailpoint.object.ProvisioningPlan.AccountRequest;

import sailpoint.object.ProvisioningResult;

import sailpoint.tools.GeneralException;


public class SendMail {

static SailPointContext context = null;

static ProvisioningPlan plan = null;

public static void main(String[] args) throws GeneralException {

Log logger = LogFactory.getLog("rule.active directory.Common.fieldvalue.create");

String userType = null;

Map emailTemplateArguments = new HashMap();

List toEmailList = new ArrayList();

EmailOptions options = new EmailOptions();

if (null != plan && null != plan.getNativeIdentity()) {

logger.debug("Got the falcon delete plan :");

List<AccountRequest> accReqList = plan.getAccountRequests();

Identity identity = context.getObjectByName(Identity.class, plan.getNativeIdentity());

if (null != identity) {

logger.debug("The identity is : " + identity);

userType = identity.getAttribute("type").toString();

for (AccountRequest acctReq: accReqList) {

ProvisioningResult provResult = acctReq.getResult();

if (AccountRequest.Operation.Modify.equals(acctReq.getOperation())

&& !provResult.getStatus().equalsIgnoreCase("faild") && null != userType

&& !userType.equalsIgnoreCase("service")) {


logger.debug("Display name" + identity.getDisplayName());

emailTemplateArguments.put("identityDiaplayName", identity.getDisplayName());


logger.debug("The email address" + identity.getAttribute("email"));

String mail = (identity.getAttribute("email") != null)? identity.getAttribute("email").toString(): null;


if (null != mail) {

toEmailList.add(mail);

options.setTo(toEmailList);

options.addVariables(emailTemplateArguments);

EmailTemplate emailTemplateUserID = context.getObjectByName(EmailTemplate.class, "emailTemplateName");

logger.debug("The emailTemplateUserID------------------------------" + emailTemplateUserID);

emailTemplateUserID.setBcc("abc@gmail.com");

context.sendEmailNotification(emailTemplateUserID, options);

logger.debug("email sent successfully-----------------------");

}

}


if (AccountRequest.Operation.Delete.equals(acctReq.getOperation())

&& !provResult.getStatus().equalsIgnoreCase("faild") && null != userType

&& !"service".equalsIgnoreCase(userType)) {

Map emailTemplaetArguments = new HashMap();

logger.debug("The falcon Display name" + identity.getDisplayName());

emailTemplaetArguments.put("identityDiaplayName", identity.getDisplayName());

String mail = (identity.getAttribute("email") != null)? identity.getAttribute("email").toString(): null;

logger.debug("Got the email address" + mail);

if (null != mail) {

logger.debug("Inside the loop testing");

toEmailList.add(mail);

options.setTo(toEmailList);

options.addVariables(emailTemplaetArguments);

EmailTemplate emailTemplateUserID = context.getObjectByName(EmailTemplate.class,"LeaveremailTemplateName");

emailTemplateUserID.setBcc("abc@gmail.com");

context.sendEmailNotification(emailTemplateUserID, options);

logger.debug("email sent successfully-----------------------");

}

}

}

}

}

}

}

Monday, August 21, 2023

Set TaskStatus

import org.apache.commons.logging.Log;

import sailpoint.api.SailPointContext;

import sailpoint.object.TaskResult;

import sailpoint.tools.GeneralException;

public class SetTaskStatus {

static Log log = null;

static SailPointContext context = null;

public static void main(String[] args) {

int count = 316;

TaskResult taskResult = null;

try {

taskResult = context.getObjectByName(TaskResult.class, "Mighty Task");

if (taskResult != null) {

taskResult.addAttribute("count", count);

taskResult.setCompletionStatus(taskResult.getCompletionStatus().Success);

}

} catch (GeneralException e) {

log.error("GeneralException: " + e.getMessage());

taskResult.setCompletionStatus(taskResult.getCompletionStatus().Error);

}

}

}

 

Saturday, May 27, 2023

Global Manager Attribute Rule

 if(identity != null @and identity.getManager() != null){

return identity.getManager();

} else{

return oldValue;

}


Thursday, February 9, 2023

Rule for Deleting AccessRequests before 365 days.

<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd">

<Rule language="beanshell" name="Rule-Purging-AccessRequests">

<Source>


import sailpoint.object.QueryOptions;

import sailpoint.object.IdentityRequest;

import sailpoint.object.Filter;

import sailpoint.object.TaskResult;

import sailpoint.object.WorkflowCase;

import sailpoint.api.Workflower;

import sailpoint.api.Terminator;

import sailpoint.tools.Util;

import sailpoint.tools.Message;


try {

Terminator terminator = new Terminator(context);

Workflower workflower = new Workflower(context);

int daysToDelete = 365;

int daysToDeleteNegative = (~(daysToDelete - 1));

Calendar cal = Calendar.getInstance();

cal.add(Calendar.DAY_OF_MONTH, daysToDeleteNegative);

Date beforeDate= cal.getTime();

QueryOptions qo = new QueryOptions();

qo.addFilter(Filter.lt("created",beforeDate));

qo.addFilter(Filter.or(Filter.eq("completionStatus", "Pending"),Filter.eq("executionStatus", "Executing")));


Iterator iterator = context.search(IdentityRequest.class,qo);

if( null!= iterator){

while(iterator.hasNext()){

IdentityRequest identityRequest = (IdentityRequest) iterator.next();

if(null != identityRequest &amp;&amp; null != identityRequest.getAttribute("taskResultId"))

{

TaskResult taskResult = context.getObjectById(TaskResult.class,identityRequest.getAttribute("taskResultId"));

if(null != taskResult &amp;&amp; null != taskResult.getAttribute("workflowCaseId"))

{

WorkflowCase workflowCase = context.getObjectById(WorkflowCase.class, taskResult.getAttribute("workflowCaseId"));

if(null != workflowCase)

{

workflower.terminate(workflowCase);

}

//terminator.deleteObject(taskResult);

}

Calendar cal2 = Calendar.getInstance();

Date verificationDate = cal2.getTime();

List msgList = new ArrayList();

Message msg = new Message();

msg.setType(Message.Type.Warn);

msg.setKey("This request has been made to terminated through a rule explicitly, since it has been there in pending queue from long back.");

msgList.add(msg);

identityRequest.setMessages(msgList);

identityRequest.setVerified(verificationDate);

identityRequest.setExecutionStatus(IdentityRequest.ExecutionStatus.Terminated);

identityRequest.setCompletionStatus(IdentityRequest.CompletionStatus.Failure);

context.saveObject(identityRequest);

context.commitTransaction();

}

}

Util.flushIterator(iterator);

}

}

catch(Exception e) {

log.error("Exception "+e.getMessage);

}

</Source>

</Rule>

Friday, July 22, 2022

Connector Rules

Pre-Iterate Rule :


It's used to perform before a Connector iterates on the data
e.g    : 
# Validating a CSV file to verify that it's in good condition / valid format
# Decrypting/converting a file to another format

e.g:    1

Identity IQ Pre-Iterate Rule to archive CSV file after Aggregation.

import java.io.File;
import java.io.IOException;
import java.io.file.Files;
import java.text.SimpleDateFormat;
import java.util.*;
import org.apache.log4j.Logger;

private static final Logger LOGGER  = Logger.getLogger(“PreIterateCSV”);

LOGGER.debug(“Enterting into PreIterateCSV rule : ”);

String fileName=(String)stats.get(“fileName”);
LOGGER.debug(“Filename : “+fileName);

String filePath=(String)stats.get(“absolutePath”);

String timeStamp = new SimpleDateFormat(“yyyyMMdd_HHmmss”).format(Calendar.getInstance().getTime());

File file =new File(filePath);

File newFile =new File(“Location” + fileName.substring(0,fileName.indexOf(‘.’)) +timeStamp+”.csv”);

try { 
Files.copy(file.toPath(), newFile.toPath());

LOGGER.debug(“File “+fileName+”is copied to Archive folder”);

} catch (IOException ex)

{       
    LOGGER.error(“Exception in Pre-Iterate Rule: “+ex.getMessage());
}

--------------------------------------------------********************---------------------------------------------

Map To Resource Object Rule    :

It's available for JDBC and Delimited File Connectors
# It's used for converting Map to Resource Object
# It will run during the Account Aggregations
# Provides a hook to control the map to resource object mapping

--------------------------------------------------********************---------------------------------------------

Post-Iterate Rule  :

# It's used to perform duties after a Connector iterates / pulls in data
# It will run during Account Aggregation
# Not required
e.g    :
Deleting, moving, or renaming files on the disk for archival storage

Aggregation Rules

Correlation Rule    :

# It's used to assign or "correlate" an application account to a specific Identity Cube
# It will run during Account Aggregations 
# It's not required but recommended
# IdentityIQ will attempt to correlate based on the Identity attribute
# Otherwise, the accounts will be marked as Orphan

e.g: 1

In this example, we will use the new account's email address to try and locate an existing Identity to hang the new account from. This rule uses the email attribute on the identity object to attempt to find an owner for the incoming link.

Map returnMap = new HashMap();

    String email = account.getStringAttribute("email");
    if ( email != null ) {
        returnMap.put("identityAttributeName", "email");
        returnMap.put("identityAttributeValue", email);
    }
    return returnMap;

e.g : 2 

In this example, we are trying to locate an existing Identity using the "firstname" and "lastname" attributes from the incoming account to generate a firstname.lastname formatted identity name.

Map returnMap = new HashMap();
    String firstname = account.getStringAttribute("firstname");
    String lastname = account.getStringAttribute("lastname");
    if ( ( firstname != null ) && ( lastname != null ) ) {
        String name= firstname + "." + lastname;
        returnMap.put("identityName", name);
    }
    return returnMap;

--------------------------------------------------********************---------------------------------------------

Creation Rule    :

It's used to set attributes on new Identity Cubes when they are created
# Attach for performing customizations at identity Cube creation time
# It will run during Account Aggregations but only on Identity Cube creation (new Identities or Orphaned Identities)
# Not required

NOTE :
Example rule to modify the given user created during aggregation or after a non-correlated pass-through authentication. A non-correlated authentication attempt. In this example, if the account is part of the Administrator group, we give a new Identity the ApplicationAdministrator capability.
e.g: 1

# Assigning passwords, IdentityIQ capabilities dynamically or workgroup definitions

import sailpoint.object.identity;

//  All identities using this creation rule will have their passwords set to Winter$2

identity.setPassword("Winter$2");

e.g: 2

import sailpoint.object.Identity;
import sailpoint.object.Capability;
import sailpoint.object.ResourceObject;

    // change the name to a combination of firstname and lastname

    String firstname = account.getStringAttribute("firstname");
    String lastname = account.getStringAttribute("lastname");
    String name  = firstname + "." + lastname;
    identity.setName(name);

    // add capabilities based on group membership

    List groups = (List)account.getAttribute("memberOf");
    if ( ( groups != null ) && ( groups.contains("Administrator") ) ) {
        identity.add(context.getObjectByName(Capability.class, "ApplicationAdministrator"));
    }

IAM, IGA & Identity Security

IAM sets up the employee's account so they can log in and access the application with their credentials. IGA makes sure that access requ...

Featured Articles