I want to get the objects where the identity is the owner of those objects (eg: Application, Managed Attribute, Bundle) using a rule. Does anyone know the code?
Hi @shruthi_m ,
Could you please explain more that what you’re looking for means what objects you want to get of an identity? either links or managed attributes or bundles or something else?
I want Application, ManagedAttributes and Bundles.
I don’t have the code ready for all those objects. But I can tell you the way to fetch it.
First, get the Identity object by using context methods.
From the Identity object, you can get whatever you want, like Bundles or ManagedAttributes etc. For better understanding, just check one identity from Debug and see in which entries those values are being stored. And try to get those entries’ value using the Identity object (If those are lists of values, then add them to one list object, or if it is a string value, then assign it to a String object, etc. And, later, you can use or return them according to your requirement.) Use the SailPoint doc API for methods and classes.
Please let me know if you need more help.
But, I want to get the objects where the identity is the owner of those objects.
Then, you can iterate those objects (Bundle, ManagedAttribute, or Application) by filtering the owner by that specific identity. I will share the code if I find it, if you need it. Meanwhile, you can try it by iterating those objects with the code.
Hi @shruthi_m,
Please refer the code which will return the application, bundle, managedAttribute where spadmin is the owner. Replace the spadmin with actual identity name.
import sailpoint.object.QueryOptions;
import sailpoint.object.Filter;
import sailpoint.object.Application;
import sailpoint.object.Identity;
import sailpoint.object.ManagedAttribute;
List appList = new ArrayList();
List bunList = new ArrayList();
List managedAttributeList = new ArrayList();
Identity identity = context.getObjectByName(Identity.class,"spadmin");
QueryOptions qp = new QueryOptions();
qp.addFilter(Filter.eq("owner",identity));
List applicationList = context.getObjects(Application.class,qp);
for(Application app:applicationList){
appList.add(app.getName()); // application name
}
List bundleList = context.getObjects(Bundle.class,qp);
for(Bundle bundle:bundleList){
bunList.add(bundle.getName()); // bundle name
}
List managedList = context.getObjects(ManagedAttribute.class,qp);
for(ManagedAttribute manAttribute:managedList){
managedAttributeList.add(manAttribute.getName()); // managedAttribute name
}
Hi @shruthi_m ,
Use below for application. And you try for other objects as well and you will get them as well.
import java.util.ArrayList;
import java.util.List;
import sailpoint.api.SailPointContext;
import sailpoint.object.Application;
import sailpoint.object.Filter;
import sailpoint.object.QueryOptions;
try {
List lisOfAppNames = new ArrayList();
Filter f1 = Filter.eq("owner.name", "Walter.Henderson"); //You can change to your identity name
QueryOptions qo = new QueryOptions();
qo.add(f1);
List listOfApps = context.getObjects(Application.class, qo);
for (Application object : listOfApps) {
lisOfAppNames.add(object.getName());
}
return lisOfAppNames;
} catch (Exception e) {
System.err.println("Exception occured at: "+e);
}
I can say that coding is an art. You can get it done in different ways using code. You can optimize the code that I have given as well. It is up to you how you handle it wisely . Feel free to comment or ping if you need more.
Both the codes are working.
Thank you.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.