I am trying to get the entitlements assigned date as well as entitlements removed to the users over last one month.
Need the same for the roles too
Can anyone help me on how to get that
We can use rule or query whatever helps
The easiest way to retrieve added or removed entitlements, assigned roles and detected roles is by querying ProvisioningTransactions.
Below is a Beanshell script that searches for entitlements and role modifications within the last month. This script logs the results to the console, but you can modify it to generate a report or store the results elsewhere based on your needs.
Note: Be cautious when running this script in production, as it may generate a large volume of logs, which could impact server performance.
import sailpoint.object.Filter;
import sailpoint.object.ProvisioningTransaction;
import sailpoint.object.ProvisioningPlan.AccountRequest;
import sailpoint.object.QueryOptions;
import java.util.List;
import java.util.Map;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.time.LocalDateTime;
import java.util.Calendar;
import java.util.Date;
// Obtain current date
Date currentDate = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(currentDate);
// Obtain date one month ago
cal.add(Calendar.MONTH, -1);
//cal.add(Calendar.DAY_OF_MONTH, -1); //For testing
Date oneMonth = cal.getTime();
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm");
SimpleDateFormat dateFormatDia = new SimpleDateFormat("dd/MM/yyyy");
String currentF = dateFormat.format(currentDate);
String oneMonthF = dateFormat.format(oneMonth);
log.debug("Searching role assignments+detections between : " + oneMonthF + " & " + currentF);
// Filter ProvisioningTransactions during previous interval
QueryOptions qo = new QueryOptions();
List filters = new ArrayList();
filters.add(Filter.ge("created", oneMonth));
filters.add(Filter.le("created", currentDate));
filters.add(Filter.eq("operation", "Modify"));
filters.add(Filter.eq("applicationName", "IdentityIQ"));
Filter f = Filter.and(filters);
qo.addFilter( f );
List provTrans = context.getObjects(ProvisioningTransaction.class, qo);
log.debug("ProvisioningTransactions found: " + provTrans.size());
if(provTrans != null){
for(prov : provTrans){
log.debug("Identity: " + prov.getIdentityName() + " - " + prov.getIdentityDisplayName());
AccountRequest request = prov.getAttributes().getMap().get("request");
if(request != null){
for(atr : request.getAttributeRequests()){
log.debug(" Date: " + dateFormat.format(prov.getCreated()));
log.debug(" Operation: " + atr.getOperation());
log.debug(" Attribute: " + atr.getName());
log.debug(" Value: " + atr.getValue());
}
}
}
}
return "ProvisioningTransaction found: " + provTrans.size();
Hope this helps! Let me know if you have any questions.
Just checking in to see if my response helped you.
If this solution resolved your issue, could you mark it as the accepted answer in the forum? This would help others facing similar challenges and also allow me to continue progressing on my journey as a SailPoint Ambassador.
Let me know if you need further assistance!