Check Account Existence by Custom Attribute in SailPoint?

We need to create an attributeGenerator rule, ensuring that a field named mailNickname does not already exist. If it does exist, we need to append a counter, similar to the example template provided in the SailPoint Developer Documentation for Attribute Generator Rules. However, the example checks the displayName using accountExistsByDisplayName, which is not suitable for our case. Based on the JavaDocs, it seems possible to check using the nativeIdentity, but is there any way to check if an account exists based on another attribute, such as mailNickname?

You can use attrSearchCountAccounts method of IdnRuleUtil

Hi @iamnithesh,

I tried following your advice, but I encountered an error when validating the rule.

Here’s the code I’m using based on the documentation you shared:

public boolean isUIDUnique(String value) throws GeneralException {
    List<String> sourceIds = new ArrayList<>();
    sourceIds.add(application.getId());

    List<String> values = new ArrayList<>();
    values.add(value);

    int countAccounts = idn.attrSearchCountAccounts(sourceIds, "mailNickname", "Equals", values);
    return countAccounts == 0;
}

However, I received the following error message:

Line 14 - [LintProcessor(0)] Could not parse line, check to ensure line is syntactically correct. Error: Encountered "=" at line 14, column 32. Error occurred between lines 10 and 14.

Could you clarify if there’s any additional setup or context needed to make this method work? I’m unsure if I’m missing something specific about the initialization of idn or the compatibility of this method with my environment.

Thanks in advance for your help!

You need to promote the account attribute to be searchable to use the same in this method.

Here is the link to the API doc for same

1 Like

You cannot use <> in your java code. Beanshell cannot parse this as <> messes up the xml that contains the script of the rule

Yes, it was fixed with this change in the code:

List sourceIds = new ArrayList(Arrays.asList(new String[] {"xxxxxxxxxxxxxx"}));

List values = new ArrayList(Arrays.asList(new String[] {value}));