Tuesday, June 8, 2021

Rule - ManagerCorrelation Example

 ManagerCorrelation Sample Rule for Sailpoint IdentityIQ

import java.util.Map;
import java.util.HashMap;
import sailpoint.object.Identity;
import sailpoint.object.Filter;
import sailpoint.object.QueryOptions;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


Map map = new HashMap();
String value = (String) link.getAttribute("supemployeeNumber");

    //If supervisorId is not null, then proceed to validate if an identity exists in IIQ with the same employeeNumber.
if (value != null) {
	QueryOptions queryOptions = new QueryOptions();
	queryOptions.add(Filter.eq("employeeNumber", value));
	Iterator iterator = context.search(Identity.class, queryOptions);

	//If an identity exists in IIQ with the same employeeNumber, proceed to return the manager.
	if (iterator.hasNext()) {
		map.put("identity", (Identity) iterator.next());
		return map;
	}
}

     //Return null explicitly in case valid manager is not found.
Identity identity = link.getIdentity();
if (identity.getManager() != null) {
	identity.setManager(null);
	context.saveObject(identity);
}
return null;