A sample code for aggregating a single account aggregation of a application

This is one of the most common useful rules that we can do quickly from the debug as well in order to aggregate a single account from a single application. All you just have to do is provide the name of the application and the native identity of the account. You can add some extra entries to the task attributes if you want. You can run this rule from debug and verify the account.

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<Rule language="beanshell" name="Test-Single-Account-Aggregation">
    <Source>
        <![CDATA[
         import sailpoint.object.Application;
         import sailpoint.object.Attributes;
         import sailpoint.object.ResourceObject;
         import sailpoint.object.TaskResult;
         import sailpoint.api.Aggregator;
         import sailpoint.connector.Connector;

         /\*
          \* Provide the appName and acctNativeIdentity below and run the rule in Debug
          \*/

         String appName = "Active Directory";

         String acctNativeIdentity = "CN=bhanuk,OU=APAC Services,DC=office,DC=bpk,DC=com";
         

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

         String appConnName = appObject.getConnector();

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

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

         if(rObj!=null) {
             Attributes argMap = new Attributes();
             argMap.put("aggregationType", "account");
             argMap.put("applications", appName);
             argMap.put("descriptionAttribute","description");
             argMap.put("descriptionLocale", "en_US");
             argMap.put("noOptimizeReaggregation", "true");

             Aggregator agg = new Aggregator(context, argMap);

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

             return rObj.toXml();
         } else {
             return "The account: " + acctNativeIdentity + " can not be found.";
         }
    ]]>
    </Source>
</Rule>
5 Likes

@bhanuprakashkuruva Thanks a lot for sharing :).

Also I’m just putting here another topic doing that same “aggregate single account“ but from a quick link by @msingh900 maybe anyone could see it useful as well :), I will do the same in the other topic as well, will put a link for your topic there too, have a nice and great one!

Have a nice and great one!

Regards,

Mustafa

Thanks for your comment. Yes it’s useful.

1 Like

Good example of using the Aggregator API!

You can find a much more expansive version of this code in my IIQ-Common-Pub library. It handles some connector-specific weirdness, as well as things like running or not running the customization rule.

1 Like

Thanks much, @drosenbauer! Much useful. Really appreciate the effort you put on it.

2 Likes