docs: public void preProcess(DirContext ctx) throws NamingException {
          LdapContext ldapContext;
          if (ctx instanceof LdapContext) {
              ldapContext = (LdapContext) ctx;
          }
          else {
              throw new IllegalArgumentException("Request Control operations require LDAPv3 - "
                      + "Context must be of type LdapContext");
          }
  
          Control[] requestControls = ldapContext.getRequestControls();
          if (requestControls == null) {
              requestControls = new Control[0];
          }
          Control newControl = createRequestControl();
  
          Control[] newControls = new Control[requestControls.length + 1];
          for (int i = 0; i < requestControls.length; i++) {
              if (replaceSameControlEnabled && requestControls[i].getClass() == newControl.getClass()) {
                  log.debug("Replacing already existing control in context: " + newControl);
                  requestControls[i] = newControl;
                  ldapContext.setRequestControls(requestControls);
                  return;
              }
              newControls[i] = requestControls[i];
          }
  
          // Add the new Control at the end of the array.
          newControls[newControls.length - 1] = newControl;
  
          ldapContext.setRequestControls(newControls);
      }