I am developing two cloud rules: one to generate user emails and another for the SAMAccountName.
For our client, internal user emails use the same logic as the SAMAccountName plus the domain.
For external users, the email is generated using a different logic, so I need to generate it in a separate rule.
What would be the best practice for generating these emails?
Is it possible to use a rule within a transform? That way, I could reuse the SAMAccountName generated for internal users and call the email rule to generate the email for external users.
Or could I retrieve the SAMAccountName within the email rule and generate the email there for both internal and external users?
From a maintainability perspective, I’d recommend having a single source of truth for the naming logic.
In SailPoint Identity Security Cloud, cloud rules cannot directly call other cloud rules, and using a rule inside a transform is generally not the best pattern for this scenario.
A common approach is:
Generate sAMAccountName in its dedicated rule
Store it as an identity attribute
In the email generation logic, reference that attribute for internal users and append the domain
Apply separate logic only for external users
This avoids duplicating the internal naming convention in multiple places. If you implement the same logic independently in both rules, you’ll eventually have to maintain it in two locations.
So yes, retrieving the generated sAMAccountName (or the underlying attributes used to create it) within the email generation process is typically the cleaner and more maintainable approach.
I’d suggest keeping the SAMAccountName logic in one place and reusing it rather than duplicating it in both rules.
For internal users, you can generate the email using the already generated SAMAccountName and append the domain. For external users, apply your separate email logic.
Unfortunately, you can’t directly call a cloud rule from a transform. A cleaner approach would be to retrieve the generated SAMAccountName within the email rule (or from an identity attribute if available) and build the email from there.
This keeps the logic centralized and makes future changes much easier to manage.
Thanks
Hi Ariel, hoping you are fine. You will not be able to control the order of evaluation, in fact each rule will trigger concurrently. What we do for this is to have 2 rules, being the second a clone of the first one but adding the @domain. One thing that is possible is to have the employees and contractors logic inside one rule (you can check if current identity has the employee source, or the contractor source to switch between each other), this would allow you to have only 2 rules (one for samaccountname and other for email). Note that cloud rules does not control concurrency, if you have 2 persons with exactly the same name, being processing at the same time, you will have a race condicion that ends in duplicate logins/email (I have already seen this).
Another and better approach, which we use whenever we can, is to use a powershell before operation (connector) rule, instead of a cloud rule. With that, you will have 100% control of behaviour, including treating race conditions (there are several ways to implement sempahores in powershell). And the better of all, you can have all logic (employees and contractors login and email) in one unique rule.
Hi @ArielM Can I ask, are you creating an Exchange mailbox for the user (whether on-prem or remote)? And if so, are you using an after create powershell? Best practice in these situations is to make AD authoritative for the email address. I would suggest generating your external user’s left hand side of the email on ISC (does it really need a rule, can it not be a transform?) and pass it to AD as an extension attribute in the create profile. Then in your after provisioning powershell use some logic such as if extension attribute x is not null use extensionattributex@domain, else sAMAccountName@domain. Then get ISC to aggregate the email address back to the Identity.
Thanks for the responses. I agree that the best solution would be to migrate these cloud rules to a single connector rule that generates the user and the email.