you may encore cases you would like to run single aggregation before an action on the account.

following rule will run it on AD.


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

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

<Rule created="1669205811708" id="0a64184786111c2981861291889706d1" language="beanshell" modified="1675355480415" name="ruleSingleADAggregation" type="Workflow">

  <Signature returnType="String">

    <Inputs>

      <Argument name="applicationName" type="String">

        <Description>

Arguments passed to the aggregation or refresh task.

</Description>

      </Argument>

      <Argument name="userDN" type="String">

        <Description>

The Identity object that represents the user

              that is being aggregated.

</Description>

      </Argument>

      <Argument name="identityName" type="String">

        <Description>

The AttributeDefinition object for this attribute.

</Description>

      </Argument>

    </Inputs>

  </Signature>

  <Source>

import java.util.ArrayList;

import java.util.Enumeration;

import java.util.HashMap;

import java.util.Hashtable;

import java.util.List;

import java.util.Map;

import sailpoint.api.SailPointContext;

import sailpoint.workflow.WorkflowContext;

import sailpoint.object.Identity;

import javax.naming.Context;

import javax.naming.NamingEnumeration;

import javax.naming.NamingException;

import javax.naming.directory.DirContext;

import javax.naming.directory.SearchControls;

import javax.naming.directory.SearchResult;

import javax.naming.ldap.InitialLdapContext;

import sailpoint.tools.Util;

import sailpoint.api.SailPointContext;

import sailpoint.object.Application;

import sailpoint.object.Attributes;

import sailpoint.tools.GeneralException;

import sailpoint.connector.Connector;

import sailpoint.object.ResourceObject;


//if (applicationName= null)

 applicationName = "Active Directory";

  

//if (userDN=null)

 String userDN ="CN=shalev_adi,OU=IT-Temp-Users,OU=All Employees,OU=Maccabi-Root,DC=testmac,DC=org,DC=il";

  

//if (identityName=null)

 identityName ="10051837";


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


if(Util.isEmpty(applicationName) || Util.isEmpty(userDN))

        {

            log.info("runADTargetedAggregation : One of required arguments is empty: applicationName,userDN");

            return;

        }

    

        // We have already validated all of the arguments.  No just load the objects.

        Application appObject = context.getObjectByName(Application.class, applicationName);

       String appConnName = appObject.getConnector();

       Connector appConnector = sailpoint.connector.ConnectorFactory.getConnector(appObject, null);

               

       ResourceObject rObj = appConnector.getObject("account", userDN, null);

                   

        

        Rule customizationRule = appObject.getCustomizationRule("account");

        if (null != customizationRule)

         {

                //Pass the mandatory arguments to the Customization rule for the app.

            HashMap ruleArgs = new HashMap();

              ruleArgs.put("context",context);

              ruleArgs.put("log",log);

              ruleArgs.put("object", rObj);

              ruleArgs.put("application", appObject);

              ruleArgs.put("connector", appConnector);

              ruleArgs.put("state", new HashMap());      

              ResourceObject newRObj = context.runRule(customizationRule, ruleArgs, null);

              if (null != newRObj) 

              {

                 rObj = newRObj;                

              }  


        }

        

           

      

        Attributes argMap = new Attributes();

        argMap.put("promoteAttributes", "true");

        argMap.put("correlateEntitlements", "true");

        argMap.put("noOptimizeReaggregation", "true");  // Note: Set to false to disable re-correlation.

               

        // Consturct an aggregator instance.

        Aggregator agg = new Aggregator(context, argMap);

        

        // Invoke the aggregation task by calling the aggregate() method.

        // Note: the aggregate() call may take serveral seconds to complete.

      TaskResult taskResult = agg.aggregate(appObject, rObj);

        

        

        if (null == taskResult) {

            String errorMessage = "ERROR: Null taskResult returned from aggregate() call. ";

            log.error(errorMessage);

            return;

        }

    

return taskResult;

    </Source>

</Rule>