Mail and ProxyAdresses unique check

We have attribute generator rule for mail and proxyAddresses uniqueness check.

For some reason it is not working.

we have existing user Vernica, Reyes and new user also came with same name

Existing user email and proxyAdresses below

email - [email protected]
proxyAdresses - smtp:[email protected]
proxyAdresses - SMTP:[email protected]

New user email and proxyAdresses created like below

email - [email protected]
proxyAdresses - SMTP: [email protected]

But expected is it should increment by 1

email - Vernica.Reyes1@company.org
proxyAdresses - SMTP: Vernica.Reyes1@company.org

Any issue in the logic.

	import java.util.ArrayList;
	import java.util.Arrays;
	import java.util.List;

	import sailpoint.object.Identity;
	import sailpoint.server.IdnRuleUtil;
	import sailpoint.tools.GeneralException;

	int maxIteration = 1000;

	public boolean isUnique ( String email ) throws GeneralException {
			boolean isValueUnique = false;
			List sourceList = new ArrayList(Arrays.asList(new String[]{ "6817f2c135d54e3dbd3df1893fe735bc", "cef2b610fc8e486d94a70d23703bc22d", "08e1b20edea4458083d66d7622a91853", "70ec8ee3b4444ad282a59ab7890b6ae0", "eed4472784514a2fa9392d66c2b770ea", "e8e667ecafa5497688ddc4309d584a77"}));
				List emailValue = new ArrayList(Arrays.asList(new String[]{email}));   
				try{					
					int identityCount = idn.attrSearchCountAccounts(sourceList, "promotedsEmail", "Equals", emailValue); 
					
					// Check on the AD and SMTP email addresses (StartsWith)
					int smtpFound = idn.attrSearchCountAccounts(sourceList, "promotedSmtpAddresses", "StartsWith", new ArrayList(Arrays.asList(new String[] {"smtp:" + email})));
					int SMTPFound = idn.attrSearchCountAccounts(sourceList, "promotedSmtpAddresses", "StartsWith", new ArrayList(Arrays.asList(new String[] {"SMTP:" + email})));
					
					if(identityCount == 0 && smtpFound == 0 && SMTPFound == 0)
					{
						isValueUnique = true;
					}		  		
				} 
				catch (GeneralException exception) {
					throw new GeneralException("Error in  isUnique Method in Generate Email ::" + exception);
				}
				return isValueUnique;
		}


	public String generateUniqueEmail(String firstname, String lastname) throws GeneralException {
			String email = "";
			String domain = "@company.org";

			if (!firstname.isEmpty() && !lastname.isEmpty()) {
				email = firstname + "." + lastname;
			}

			if (!firstname.isEmpty() && lastname.isEmpty()) {
				email = firstname;
			}

			if (firstname.isEmpty() && !lastname.isEmpty()) {
				email = lastname;
			}
			try {
				String emailWithDomain = email + domain;
				if (isUnique(emailWithDomain)) {
					return emailWithDomain;
				}
				String updatedEmail = "";
				for (int n = 1; n <= maxIteration; n++) {
					updatedEmail = email + n;
					String updatedEmailWithDomain = updatedEmail + domain;
					if (isUnique(updatedEmailWithDomain)) {
						return updatedEmailWithDomain;
					}
				}	
			}catch (GeneralException exception) {
				throw new GeneralException("Error in generateUniqueEmail Method in Generate Email::" + exception);
			}
			return email;
		}


	String firstname = null != identity.getFirstname() ? identity.getFirstname().replaceAll("[^a-zA-Z]", "") : "";
	String lastname = null != identity.getLastname() ? identity.getLastname().replaceAll("[^a-zA-Z]", "") : "";

	return generateUniqueEmail(firstname,lastname);

How is your source list coming through?

There was an issue where parameters were lost on account creation profiles. It should now be fixed. If you have custom parameters, they may have been lost and need to be re-populated.

the below showing create profile for mail and proxyAddresses and Promoted mail and proxyAdresses and we are provisioning to source id 08e1b20edea4458083d66d7622a91853

 {
            "name": "mail",
            "transform": {
                "attributes": {
                    "name": "Generate Email"
                },
                "type": "rule"
            },
            "attributes": {},
            "isRequired": false,
            "type": "string",
            "isMultiValued": false
        }
     {
            "name": "proxyAddresses",
            "transform": {
                "attributes": {
                    "value": "SMTP:$mail"
                },
                "type": "static"
            },
            "attributes": {},
            "isRequired": false,
            "type": "string",
            "isMultiValued": false
        }
{
    "name": "promotedsEmail",
    "displayName": "Promoted Mail Addresses",
    "applicationAttributes": {
        "6817f2c135d54e3dbd3df1893fe735bc": "mail",
        "cef2b610fc8e486d94a70d23703bc22d": "mail",
        "08e1b20edea4458083d66d7622a91853": "mail",
        "70ec8ee3b4444ad282a59ab7890b6ae0": "mail",
        "eed4472784514a2fa9392d66c2b770ea": "mail"
    }
}
{
    "name": "promotedSmtpAddresses",
    "displayName": "Promoted proxyAddresses",
    "applicationAttributes": {
        "6817f2c135d54e3dbd3df1893fe735bc": "proxyAddresses",
        "cef2b610fc8e486d94a70d23703bc22d": "proxyAddresses",
        "08e1b20edea4458083d66d7622a91853": "proxyAddresses",
        "70ec8ee3b4444ad282a59ab7890b6ae0": "proxyAddresses",
        "eed4472784514a2fa9392d66c2b770ea": "proxyAddresses"
    }
}

Hi @gayare ,
Greetings of the Day!

please recheck source IDs and attributes .

Rule is looking fine.

Thank you

3 Likes

Hi @gayare ,
Good Day!

Kindly check promotedSmtpAddresses is populated in all the source that you have mentioned in the code because many times it is not updated and as you are using promotedSmtpAddresses attribute to check uniqueness. If it is not updated please do unoptimized aggregation.
Rest code is perfect.
PS: You can add one more idnruleutil method i.e. isUniqueLDAPValue for double checking​:blush:
Thank you!

5 Likes