@SuppressWarnings("rawtypes")
  protected void applyRequestControls(AbstractQuery query) {

    try {
      List<Control> controls = new ArrayList<Control>();

      String orderBy = query.getOrderBy();
      if (orderBy != null) {
        orderBy = orderBy.substring(0, orderBy.length() - 4);
        if (UserQueryProperty.USER_ID.getName().equals(orderBy)) {
          controls.add(new SortControl(ldapConfiguration.getUserIdAttribute(), Control.CRITICAL));

        } else if (UserQueryProperty.EMAIL.getName().equals(orderBy)) {
          controls.add(
              new SortControl(ldapConfiguration.getUserEmailAttribute(), Control.CRITICAL));

        } else if (UserQueryProperty.FIRST_NAME.getName().equals(orderBy)) {
          controls.add(
              new SortControl(ldapConfiguration.getUserFirstnameAttribute(), Control.CRITICAL));

        } else if (UserQueryProperty.LAST_NAME.getName().equals(orderBy)) {
          controls.add(
              new SortControl(ldapConfiguration.getUserLastnameAttribute(), Control.CRITICAL));
        }
      }

      initialContext.setRequestControls(controls.toArray(new Control[0]));

    } catch (Exception e) {
      throw new IdentityProviderException("Exception while setting paging settings", e);
    }
  }