Email Generation duplication processing via ISC cloud rule and its debugging best practices

Hello colleagues,

I’m currently working on the building the during provisioning cloud rule that generates email from firstName and lastName and populates Active Directory as a targeted app with it.

Its simplified logic is
{firstName}.{lastName}[counter if its a duplicate]@{domain}
But of course it varies a bit according to the parameters and I’m doing it with COUNTRY_SCHEMA map.

Here is the code snippet:

        // Replaces diacritical marks and removes special chars
        public String sanitizeString(String input) throws GeneralException {
            log.info("Entering - sanitizeString()");
            String result = input;
            
            for (Object key : replaceMap.keySet()) {
                result = result.replace(key.toString(), replaceMap.get(key).toString());
            }
            
            result = result.replaceAll("[^a-zA-Z0-9]", "");
            
            log.info("Leaving - sanitizeString() with result: " + result);
            return result;
        }

        // Parses the first part of LastName
        public String processLastName(String lastName, boolean toKeepPrefix) throws GeneralException {
            log.info("Entering - processLastName()");
            lastName = lastName.trim();
            if (lastName.contains(" ")) {
                String[] parts = lastName.split(" ");
                if (toKeepPrefix) {
                    log.info("Leaving - processLastName() with result: " + parts[0]);
                    return parts[0];
                } else {
                    log.info("Leaving - processLastName() with result: " + String.join("", parts));
                    return String.join("", parts);
                }
            }

            log.info("Leaving - processLastName() with result: " + lastName);
            return lastName;
        }

        // Checks the existence of the generated email in the source app
        public boolean isEmailUnique(String email) throws GeneralException {
            log.info("Entering - isEmailUnique()");
            List sourceIds = new ArrayList();
            sourceIds.add(application.getId());
            String attributeName = "mail";
            String operation = "Equals";
            List values = new ArrayList();
            values.add(email);

            int count = idn.attrSearchCountAccounts(sourceIds, attributeName, operation, values);

            boolean result = count == 0;

            log.info("Leaving - isEmailUnique() with result: " + result);
            return result;
        }

        // Main function to generate email
        public String generateEmail(String firstName, String lastName, String countryCode) throws GeneralException {
            try {
                log.info("Entering - generateEmail()");
                log.info("Input Parameters for generateEmail: " + "firstName=" + firstName + " lastName=" + lastName + " countryCode=" + countryCode);
                log.warn("generateEmail - current IDN: " + idn);
                log.warn("generateEmail - current APPLICATION: " + application);
                firstName = StringUtils.trimToNull(firstName);
                lastName = StringUtils.trimToNull(lastName);
                countryCode = StringUtils.trimToNull(countryCode);

                if (firstName == null || lastName == null || countryCode == null) {
                    throw new GeneralException("Missing required attributes for email generation");
                }

                String schema = COUNTRY_SCHEMA.getOrDefault(countryCode, COUNTRY_SCHEMA.get("default"));
                boolean toKeepPrefix = schema.contains("{lastNamePrefix}");

                String lastNamePrefix = "";
                if (toKeepPrefix) {
                    for (String prefix : LASTNAME_PREFIXES) {
                        if (lastName.toLowerCase().startsWith(prefix)) {
                            lastNamePrefix = prefix.replace(" ", "");
                            lastName = lastName.substring(prefix.length()).trim();
                            break;
                        }
                    }
                } else {
                    for (String prefix : LASTNAME_PREFIXES) {
                        if (lastName.toLowerCase().startsWith(prefix)) {
                            lastName = lastName.substring(prefix.length()).trim();
                            break;
                        }
                    }
                }

                String firstLastName = processLastName(lastName, toKeepPrefix);

                firstName = sanitizeString(firstName);
                firstLastName = sanitizeString(firstLastName);
                lastName = sanitizeString(lastName);

                String firstCharFirstname = firstName.substring(0, 1);

                String email = schema
                    .replace("{firstname}", firstName)
                    .replace("{firstCharFirstname}", firstCharFirstname)
                    .replace("{lastNamePrefix}", lastNamePrefix)
                    .replace("{firstLastName}", firstLastName)
                    .replace("{lastname}", lastName);

                int counter = 1;
                String baseEmail = email;
                while (!isEmailUnique(email)) {
                    if (counter > 49) {
                        throw new GeneralException("Exceeded maximum number of email duplicates");
                    }

                    email = baseEmail.replace("@", counter + "@");
                    counter++;

                }

                log.info("Leaving - generateEmail() with the result: " + email.toLowerCase());
                return email.toLowerCase();
            } catch (Exception e) {
                log.error("Error in generateEmail for user: " + identity.getDisplayName(), e);
                throw new GeneralException("GenerateMail failed for user: " + identity.getDisplayName(), e);
            }
        }

        return generateEmail(identity.getFirstname(), identity.getLastname(), identity.getStringAttribute("countryCode"));

and dealing the issue with the email duplication processing.
Despite the RDK built tests work out and result the expected value.

    @Test
    public void testUniqueLogic () throws GeneralException, EvalError {
        Interpreter i = new Interpreter();

        IdnRuleUtil idn = mock();
        when(idn.attrSearchCountAccounts(any(), any(), any(), any())).thenReturn(1).thenReturn(0);
        log.info("SOME OBJECT " + idn);
        Application application = mock(Application.class);
        when(application.getId()).thenReturn("12345");

        Identity identity = mock(Identity.class);
        when(identity.getFirstname()).thenReturn("Trox");
        when(identity.getLastname()).thenReturn("Marmox");
        when(identity.getStringAttribute("countryCode")).thenReturn("IT");
        String result = "";

        i.set("log", log);
        i.set("idn", idn);
        i.set("application", application);
        i.set("identity", identity);

        String source = RuleXmlUtils.readRuleSourceFromFilePath(RULE_FILENAME);
        result = (String) i.eval(source);

        assertNotNull(result);
        assertEquals(result, "[email protected]");

        log.info("Beanshell script returned: " + result);

    }

My assumption that there is a mistake with isEmailUnique function because in the Sailpoint UI after the provisioning to AD I see an empty Email field in the corresponding AD account attributes.

I would really appreciate if u could guide me with debugging the code and share ur best practices to debug such kind of rules.

As far as i know since it’s cloud based rule, my only tools to test and debug it are RDK with UNIT tests or to write the similar Java Function and there were no bugs spotted as i said.

As you have noticed I was also trying to distribute the logs through the code to check the code execution flow but I’ve discovered that they are not visible because it’s a cloud Rule.

is there a way to check the logs in these Rules? Probably I need to change the logging level or sth else?

Thank u for you input in advance and any related advice.

Hi @Blazelip ,
You can raise a sailpoint support ticket for cloud rule logs. One simple trick to check cloud rule is try the same rule in a IIQ instance( if you have).
Also if you are only using {firstName}.{lastName}[counter] if its a duplicate]@{domain} this logic , I believe ISC provides an OOTB feature for this as well, in create policy it will be generator $(firstName).$(lastName)$(uniqueCounter)@domain.com

Hi @Blazelip

I would query why you are using a cloud rule to generate the unique username, when as @gourab says, there is an OOTB connector which does this all for you.
This is mine:

        {
            "name": "sAMAccountName",
            "transform": {
                "type": "rule",
                "attributes": {
                    "name": "Create Unique LDAP Attribute"
                }
            },
            "attributes": {
                "template": "$(samaccountnameCalculate)$(uniqueCounter)",
                "cloudMaxUniqueChecks": "10",
                "cloudMaxSize": "20",
                "cloudRequired": "true"
            },
            "isRequired": true,
            "type": "string",
            "isMultiValued": false
        },

The logic of building the email address is a bit more complicated than I presented (because it was easy to put you on to the issue).

The final template depends on the user’s country.

I also process lastName prefixes, like “van de”, take the first part of lastName if it has 2 words, fi, “Lex Krieger” and also sanitize the string removing/replacing the special chars, like German lang umlauts, etc.

When I started to estimate efforts pondering the OOTB feature or the Cloud Rule: I’ve decided to go with rules since they have more capacity to be customized.

I’m generating the email, but with the Username I do ± the same stuff, but the logic is even more complicated, cause the possible counter doesn’t append with the firstName/lastName, I’m cutting the letters from the end and replacing them with the counter.

As I said, during the estimation I thought that OOTB node is not able to do this.

If you have complex requirements as you mentioned then yes attribute generator is more feasible. Make sure to set the attributes as searchable before using the rule

Using the OOTB connector and transforms:
Create a systemID from: firstName lastName (this also checks for the presence of a preferredName), if they are Dutch it inserts their ‘tussenvoegsel’ as that is a legal requirement, insert a ‘.’ between the names I then remove all diacritic marks and replace with latin equivalents, lowercase the output, then strip any none letters using “regex”: “[^a-zA-Z]”,
Then to create the sAMAccountName, I cut the systemID down to less than 18 characters.
This goes through the LDAP rule to create the number.
I then strip this number and attach that back to the systemID which is used to create their email and username.

I think that covers all that you are trying to achieve without having to go to cloud rules, but admittedly I don’t like working in java/Beanshell, so if you are more comfortable coding in that language, then that makes sense.
DM me if you want my JSON code

1 Like

Thank u for the quick reply,

Could we go together through the attributes of my tenant and make sure that all the required attributes marked as searchable?

Probably I’ve met the similar issue here

But I’m confused what should I do in my case next.

Here is the responce of Get call to endpoint: {{baseUrl}}/identity-attributes

[
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "city",
        "displayName": "City",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "costCenter",
        "displayName": "Cost Center",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "country",
        "displayName": "Country",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "department",
        "displayName": "Department",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "displayName",
        "displayName": "att_display_name",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "email",
        "displayName": "att_email",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "endDate",
        "displayName": "End Date",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "firstname",
        "displayName": "att_first_name",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "identificationNumber",
        "displayName": "Employee Number",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "initials",
        "displayName": "Initials",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "lastname",
        "displayName": "att_last_name",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "licenseStatus",
        "displayName": "License Status",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "location",
        "displayName": "Location",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "locationCode",
        "displayName": "Location Code",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "applicationMapping",
                "properties": {
                    "attribute": null,
                    "sourceName": "IdentityNow Admins"
                }
            },
            {
                "type": "applicationMapping",
                "properties": {
                    "attribute": null,
                    "sourceName": "NOE HR Feed"
                }
            },
            {
                "type": "applicationMapping",
                "properties": {
                    "attribute": null,
                    "sourceName": "SAP HCM DEV"
                }
            },
            {
                "type": "applicationMapping",
                "properties": {
                    "attribute": null,
                    "sourceName": "SAP HCM Dummy Source"
                }
            }
        ],
        "name": "manager",
        "displayName": "att_manager",
        "standard": true,
        "type": "sailpoint.object.Identity",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "middleName",
        "displayName": "Middle Name",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "nextProcessing",
        "displayName": "Next Processing Date",
        "standard": true,
        "type": "String",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "organization",
        "displayName": "Organization",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "personalEmail",
        "displayName": "Personal Email",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "phone",
        "displayName": "Personal Phone",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "postalCode",
        "displayName": "Postal Code",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "preferredLanguage",
        "displayName": "Preferred Language",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "preferredName",
        "displayName": "Preferred Name",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "startDate",
        "displayName": "Start Date",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "state",
        "displayName": "State",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "streetAddress",
        "displayName": "Street Address",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "timezone",
        "displayName": "Timezone",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "title",
        "displayName": "Title",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "uid",
        "displayName": "IdentityNow Username",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "workPhone",
        "displayName": "Work Phone",
        "standard": true,
        "type": "string",
        "multi": false,
        "searchable": true,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "accessCardNumber",
        "displayName": "Access Card Number",
        "standard": false,
        "type": "string",
        "multi": false,
        "searchable": false,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "addn",
        "displayName": "adDn",
        "standard": false,
        "type": "string",
        "multi": false,
        "searchable": false,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "admanagerdn",
        "displayName": "adManagerDN",
        "standard": false,
        "type": "string",
        "multi": false,
        "searchable": false,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "adou",
        "displayName": "ADOU",
        "standard": false,
        "type": "string",
        "multi": false,
        "searchable": false,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "cloudLifecycleState",
        "displayName": "Lifecycle State",
        "standard": false,
        "type": "String",
        "multi": false,
        "searchable": false,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "companyName",
        "displayName": "Company Name",
        "standard": false,
        "type": "string",
        "multi": false,
        "searchable": false,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "contract",
        "displayName": "Contract",
        "standard": false,
        "type": "string",
        "multi": false,
        "searchable": false,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "countryCode",
        "displayName": "Country Code",
        "standard": false,
        "type": "string",
        "multi": false,
        "searchable": false,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "employeeType",
        "displayName": "Employee Type",
        "standard": false,
        "type": "string",
        "multi": false,
        "searchable": false,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "fullname",
        "displayName": "Fullname",
        "standard": false,
        "type": "string",
        "multi": false,
        "searchable": false,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "internal",
        "displayName": "internal",
        "standard": false,
        "type": "string",
        "multi": false,
        "searchable": false,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "nickname",
        "displayName": "Nickname",
        "standard": false,
        "type": "string",
        "multi": false,
        "searchable": false,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "orgunit",
        "displayName": "orgUnit",
        "standard": false,
        "type": "string",
        "multi": false,
        "searchable": false,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "samaccountname",
        "displayName": "sAMAccountName",
        "standard": false,
        "type": "string",
        "multi": false,
        "searchable": false,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "subEGroup",
        "displayName": "Sub E Group",
        "standard": false,
        "type": "string",
        "multi": false,
        "searchable": false,
        "system": false
    },
    {
        "sources": [
            {
                "type": "rule",
                "properties": {
                    "ruleType": "IdentityAttribute",
                    "ruleName": "Cloud Promote Identity Attribute"
                }
            }
        ],
        "name": "telefax",
        "displayName": "Telefax",
        "standard": false,
        "type": "string",
        "multi": false,
        "searchable": false,
        "system": false
    }
]

My code of the isEmailUnique

        public boolean isEmailUnique(String email) throws GeneralException {
            log.info("Entering - isEmailUnique()");
            List sourceIds = new ArrayList();
            sourceIds.add(application.getName());
            String attributeName = "mail";
            String operation = "Equals";
            List values = new ArrayList();
            values.add(email);

            int count = idn.attrSearchCountAccounts(sourceIds, attributeName, operation, values);

            boolean result = count == 0;

            log.info("Leaving - isEmailUnique() with result: " + result);
            return result;
        }

I am a developer, so I definitely more like to debug the Java-like code then to deal with the complicated transform.
But thank u for the input anyway, if I fail the mission with rules, I would reach you out.

1 Like

When I configured the searchable attribute for the proper work of idn.attrSearchCountAccounts method, then everything worked out.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.