I would like to know if it is possible to get an Identity object using an identity attribute such as ‘employeeNumber’. In most cases, we can directly retrieve an Identity object using the identityName, as shown below:
you can use context.search(Identity.class,QueryOption); Where you build the QO with a filter on the attribute that you want, the attribute must be Searchable.
I prefer to do something extra just to return the identity only if it doesn’t match to two identity cubes. It shouldn’t happen, but assumptions get us burnt all the time:
QueryOptions op = new QueryOptions();
op.add(Filter.eq("employeeId", enterpriseId));
op.setResultLimit(2); // Limit results for speed
List users = context.getObjects(Identity.class, op);
if (users.size() > 1) {
log.error("Found multiple Identities with the same employeeId " + employeeId);
}
if (users.size() == 1) {
return (Identity) users.get(0);
}