Setting multiple possible values for AD/LDAP profile attributes

Problem statement

We have a requirement to check if a new Active Directory attribute: otherEmail has a value, then use this value to map to the ‘email’ field, otherwise if the new Active Directory attribute: otherEmail is empty (null), then map the ‘email’ field to the value of Active Directory Email attribute.

If Active Directory otherEmail = $null
then email = Active Directory Email
else email = Active Directory otherEmail


In this case, you can do the mappings in the profileMapper so that this mapping logic is completely invisible to Auth0, which will only see an “email” (regardless of how it was calculated), as you can see here:

You can set this up similar to the following:

emails: raw_data.otherEmail ? [{value: raw_data.otherEmail }] : (raw_data.mail ? [{value: raw_data.mail }] : undefined)