I have found a possible recent regression of search with QueryBuilder.
This code in groovy expression worked for us previously and found appropriate users:
ownerRoleOid = basic.stringify(ownerObject.getOid())
ObjectFilter userFilter = QueryBuilder.queryFor(UserType.class, midpoint.getPrismContext()).item(UserType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(ownerRoleOid).buildFilter();
This is current debug serialization of created filter:
This is a prove that we really have such user:
type="c:RoleType"><!-- SCHVALOVATEL_ROLE_XXX --></targetRef>
Also I can easily modify the search so that it works as expected by using role membership ref instead of assignment:
ownerRoleOid = new PrismReferenceValue(ownerObject.getOid(), RoleType.COMPLEX_TYPE); ownerRoleOid.setRelation(SchemaConstants.ORG_DEFAULT);
ObjectFilter userFilter = QueryBuilder.queryFor(UserType.class, midpoint.getPrismContext()).item(UserType.F_ROLE_MEMBERSHIP_REF).ref(ownerRoleOid).buildFilter();
Note that in this snippet I have also modified the value to contain also the relation, but assignment search don't work for both variants - string oid and prism reference value with relation. This snippet produces this search:
In query playground both filters works as expected.