QueryOptions qo = new QueryOptions();
qo.addFilter(Filter.eq(“identity.name”, identity.getName()));
qo.addFilter(Filter.eq(“application.name”, “AD Application which is as per your project”));
Iterator it = context.search(IdentityEntitlement.class, qo);
while (it != null && it.hasNext())
{
IdentityEntitlement ent = (IdentityEntitlement) it.next();
//from here you can add your logic
//alshahim alshahim - Please try this code
Hi since the entitlement is removed from the AD account but still appears as Source = Assignment, it may be a leftover AttributeAssignment (sticky entitlement).
It explains how sticky entitlements can remain on the Identity even after the entitlement is removed from the account, causing them to be re-provisioned during Identity Refresh. The article also provides a cleanup rule that can be used as a Pre-Refresh Rule or Rule Runner Task to remove orphaned AttributeAssignments.