Saturday, April 23, 2022

How to get Log4j 2 version using Standalone rule?

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

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

<Rule language="beanshell" name="Log4j 2 version">

  <Signature>

    <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>

    </Inputs>

  </Signature>

  <Source>

  String version = org.apache.logging.log4j.util.PropertiesUtil.class.getPackage().getImplementationVersion();

    return version;

  </Source>

</Rule>


LifeCycle Event Rule

   System.out.println("Entering into DND Leaver Event Rule : ");

  String status=newIdentity.getAttribute("status");

  System.out.println("status : "+status);

  if(status != null){

    if(status.equalsIgnoreCase("Terminated-N-Non Employee")){

      boolean flag = true;

      System.out.println("Entering into DND Leaver Event Rule : "+flag);      

      return flag;

    }

       else {

          boolean flag = false;

         System.out.println("Entering into DND Leaver Event Rule : "+flag);        

         return flag;

       }

 System.out.println("Exiting from the DND Leaver Event Rule : ");

       }

Customization Rule

  import org.apache.log4j.Logger;

  import org.apache.log4j.Level;


  // If the status has been populated with "Terminated-N-Non Employee" set the account to disabled.

  System.out.println("HR System CustomizationRule");

  Logger log = Logger.getLogger("HR System CustomizationRule");

  log.setLevel((Level) Level.DEBUG);

  String acctName = object.getIdentity();

  System.out.println("Account Name = "+acctName);

  System.out.println("Object = "+object);

  String status = object.getAttribute("Status");

  System.out.println("Status = "+status);


  if ( (null != status) &amp;&amp; (0 != status.length()) ) {

    if ("Terminated-N-Non Employee".equalsIgnoreCase(status)) {

      object.put("IIQDisabled", true);

      System.out.println("The 'status' set to Terminated-N-Non Employee on [" + acctName + "], marking IIQDisabled as true.");

      log.debug("The 'status' set to Terminated-N-Non Employee on [" + acctName + "], marking IIQDisabled as true.");

    }else {

      object.put("IIQDisabled", false);

    }

  } else {

    System.out.println("No 'status' field populated on [" + acctName + "], assuming active account.");

    log.debug("No 'status' field populated on [" + acctName + "], assuming active account.");

  }

  return object;

Wednesday, April 13, 2022

LDAPConnection suing Java Code

import java.util.Hashtable;

import javax.naming.Context;

import javax.naming.NamingException;

import javax.naming.ldap.InitialLdapContext;

import javax.naming.ldap.LdapContext;


public class LdapConnection {

     public static void main(String[] args) {

          Hashtable env = new Hashtable();

          env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");

          env.put(Context.PROVIDER_URL,"ldap://localhost:389");

          try {

               LdapContext ctx = new InitialLdapContext(env,null);

               System.out.println("LDAP Connection Successful");

               System.exit(0);

          } catch (NamingException e) {

               System.err.println("LDAP Notifications failure. " + e.getMessage());

               System.exit(1);

          }

      }

}

Fetch Members from Workgroup

  import java.util.ArrayList;   import java.util.Iterator;   import java.util.List;   import sailpoint.api.ObjectUtil;   import sailpoint.ob...