Friday, September 11, 2009

IP RESTRICTION FOR A DATABASE USER

CREATE OR REPLACE TRIGGER ip_restrict
AFTER LOGON ON DATABASE
DECLARE
v_user VARCHAR2 (30);
BEGIN
SELECT USER
INTO v_user
FROM DUAL;

IF v_user = 'SCOTT' THEN
IF SYS_CONTEXT ('USERENV', 'IP_ADDRESS') NOT IN ('IP1', 'IP2') THEN
raise_application_error (-20001, 'Access restricted for this IP');
END IF;
END IF;
END;

No comments: