Created
February 14, 2022 09:09
-
-
Save ajin/d8bd16805bf50094e18df5ccfcc3ae1f to your computer and use it in GitHub Desktop.
This rule will update the Entitlement Owner with the identity specified in the Link attribute ManagedBy (DN)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0' encoding='UTF-8'?> | |
<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd"> | |
<Rule language="beanshell" modified="1644587138647" name="AT Update Entitlement Owner with ManagedBy attribute"> | |
<Source> | |
// Below code will search for ManagedBy attibute (link attribute) to find a particular owner for the entitlement. | |
// A link attribute must be made searchable by adding it to the account mapping. | |
// Go to System Setup -> "Account Mappings" and click "Add New Attribute". Give it a name 'distinguishedName'. | |
// Click "Add Source" and select "Application Attribute". | |
// Aggregate the application that was specified above | |
import sailpoint.object.*; | |
import sailpoint.api.*; | |
import sailpoint.util.*; | |
String applicationName = "Active Directory"; | |
String managedAttributeId = "0a0028357e141ccc817ec67367807acf"; | |
Identity owner = null; | |
ManagedAttribute managedAttribute = (ManagedAttribute) context.getObjectById(ManagedAttribute.class, managedAttributeId); | |
String distinguishedName = managedAttribute.getAttribute("managedBy"); | |
Filter filter = Filter.and( | |
Filter.eq("application.name", applicationName) | |
, Filter.eq("distinguishedName", distinguishedName) | |
); | |
QueryOptions options = new QueryOptions(); | |
options.add(filter); | |
List links = context.getObjects(Link.class, options); | |
if (!links.isEmpty()){ | |
Link link = links.get(0); | |
owner = link.getIdentity(); | |
managedAttribute.setOwner(owner); | |
context.saveObject(managedAttribute); | |
context.commitTransaction(); | |
} | |
return owner; | |
</Source> | |
</Rule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment