Tuesday, May 26, 2015

OIM 11G R2 PS2 (11.1.2.2.0) Sample search user code

In this post I will share some sample code to search user based on a custom user attribute and also while searching some of the attribute label that do not work.


public List<User> fetchUsers(String attributeName, String attributeValue)
            throws UserSearchException, AccessDeniedException {
        UserManager um = Platform.getService(UserManager.class);

        SearchCriteria sc = new SearchCriteria(attributeName, attributeValue,
                SearchCriteria.Operator.EQUAL);

        Set<String> retAttrs = new HashSet<String>();

        retAttrs.add(UserManagerConstants.AttributeName.USER_LOGIN.getId());

        List<User> users = um.search(sc, retAttrs, null);

        return users;

    }
 
 
Couple of attribute name label that does not work in code are
USR_UDF_COLUMN
usr_udf_column
Label Name defined in user entity form
Users.attribute name if defined via design console
The label name that will work will be name as defined on user entity form without any spaces.