Saturday 16 June 2018

OIM API - How to Get Members of Admin Role?

public void getAdminRoleMembers(String adminRolename) {
    String logp = CN + "getAdminRoleMembers";
    logger.info(logp + "START");
    Connection connection = null;
    ResultSet rs = null;
    try {
        connection = Platform.getOperationalDS().getConnection();

        String sql = "select usr.usr_login from admin_role_membership,admin_role,usr where admin_role_membership.user_id = usr.usr_key and admin_role_membership.role_id = admin_role.role_id and admin_role.role_name = ?";


        PreparedStatement preparedStatement = null;
        preparedStatement = connection.prepareStatement(sql);
        preparedStatement.setString(1, adminRolename);
        rs = preparedStatement.executeQuery();
        logger.info(logp + "Members count :: " + rs.getFetchSize());
       
        while(rs.next()){
            logger.info(logp + "User Login :: " + rs.getString(1));
        }
    } catch (Exception e) {
        logger.error(logp + " Exception while getting members of admin role " + e);
    } finally {
        try {
            rs.close();
            connection.close();
        } catch (Exception e) {
            logger.error(logp + " Exception while closing connection : " + e);
        }
    }
    logger.info(logp+ "END");
}


Happy Learning!!!

No comments:

Post a Comment