Skip to main content

Account Profile Attribute Generator

Overview

This rule generates complex account attribute values during provisioning, e.g. when creating an account. You would typically use this rule when you are creating an account to generate attributes like usernames, first time passwords, or email addresses.

Execution

  • Cloud Execution - This rule executes in the Identity Security Cloud cloud, and it has read-only access to Identity Security Cloud data models, but it does not have access to on-premise sources or connectors.
  • Logging - Logging statements are currently only visible to SailPoint personnel.

Rule Execution

Input

ArgumentTypePurpose
logorg.apache.log4j.LoggerLogger to log statements. Note: This executes in the cloud, and logging is currently not exposed to anyone other than SailPoint.
idnsailpoint.server.IdnRuleUtilProvides a read-only starting point for using the SailPoint API. From this passed reference, the rule can interrogate the Identity Security Cloud data model including identities or account information via helper methods as described in IdnRuleUtil.
identitysailpoint.object.IdentityReference to identity object representing the identity being calculated.
applicationsailpoint.object.ApplicationRead-only reference to application object that represents the source to which provisioning is being done.
fieldsailpoint.object.FieldField object used to get information about the attribute being generated.

Output

ArgumentTypePurpose
valuejava.lang.ObjectValue returned for the account attribute.

Template

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<Rule name="Example Rule" type="AttributeGenerator">
<Description>Describe your rule here.</Description>
<Source><![CDATA[

// Add your logic here.

]]></Source>
</Rule>

Example - Generate Username

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<Rule language="beanshell" name="Generate Username" type="AttributeGenerator">
<Description>This will generate a username.</Description>
<Source><![CDATA[
import sailpoint.tools.GeneralException;
import java.util.Iterator;
import sailpoint.object.*;
import java.util.ArrayList;
import sailpoint.api.*;
import sailpoint.object.*;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.lang.StringUtils;

int maxIteration = 1000;

public String generateUsername ( String firstName, String lastName, int iteration ) {

// Data protection.
firstName = StringUtils.trimToNull( firstName );
lastName = StringUtils.trimToNull( lastName );

if ( ( firstName == null ) || ( lastName == null ) )
return null;

// This will hold the final username;
String username = null;

switch ( iteration ) {
case 0:
username = firstName + "." + lastName;
break;
default:
username = firstName + "." + lastName + ( iteration - 1 );
break;
}
if ( isUnique ( username ) )
return username;
else if ( iteration < maxIteration )
return generateUsername ( firstName, lastName, ( iteration + 1 ) );
else
return null;
}

public boolean isUnique ( String username ) throws GeneralException {
return !idn.accountExistsByDisplayName(application.getName(), username);
}

return generateUsername( identity.getFirstname(), identity.getLastname(), 0 );

]]></Source>
</Rule>