I want to restrict Oracle users from logging into database except for a couple of terminal. I have written below trigger.

```
CREATE OR REPLACE TRIGGER TRG_IP_RESTRICT
  AFTER LOGON ON DATABASE

DECLARE
  V_USER  VARCHAR2(30);
  V_GRP   VARCHAR2(50);   
BEGIN

  SELECT USER INTO V_USER FROM DUAL;

  V_GRP := SYS_CONTEXT('USERENV', 'TERMINAL');

  IF V_USER IN ('<list of users>') THEN
    IF V_GRP NOT IN ('<list of terminals>') THEN

      RAISE_APPLICATION_ERROR(-20001,
                              'Access Denied by DBA TEAM : ' || V_GRP ||
                              ' on ' || V_USER || ' from ' ||
                              SYS_CONTEXT('USERENV', 'IP_ADDRESS'));

    END IF;
  END IF;
END;

```

---

Even though it's working fine and going in exception part, which should happen technically. But at the same time, it is allowing the connection instead of showing the error message to the user. 

Can someone please help?