了解Maclean Liu|向Maclean Liu提问 Oracle ALLSTARS 全明星(群内有多位Oracle高级售后support,N位OCM和ACE) QQ群 # QQ群号:23549328 # 已经升级到 2000人群,空位多多。欢迎有一定基础的Oracle骨友加入,现在入群需要经过Maclean的技术面试,欢迎面试,请加QQ号:47079569 为好友参加面试 2群基础群 适合刚入门的同学,会共享最佳入门实践和资料 QQ群 # QQ群号:171092051 # 已经升级到 500人的超级群,空位多多,无需面试

危险的Alter User权限

Alter user 是Oracle数据库系统中十分powerful的权限,可以修改一般用户的属性例如默认表空间、profile等,甚至于可以修改SYS用户的密码。所以该权限是十分危险的, 在赋权时要十分小心。 针对现有用户已经拥有ALTER USER权限的,又不能revoke回来的,可以考虑使用如下触发器的方法,禁止任何拥有Alter user权限的用户修改SYSDBA的密码:    

SQL> grant alter user to alteruser;

Grant succeeded.

SQL> select * from DBA_SYS_PRIVS where grantee like 'ALTER%USER%';

GRANTEE              PRIVILEGE                 ADMIN_
-------------------- ------------------------- ------
ALTERUSER            UNLIMITED TABLESPACE      NO
ALTERUSER            ALTER USER                NO

SQL> conn  / as sysdba
Connected.

SQL> CREATE or REPLACE TRIGGER prohibit_alter_SYSTEM_SYS_pass 
          BEFORE ALTER on ALTERUSER.schema
          BEGIN
               IF ora_sysevent='ALTER' and ora_dict_obj_type = 'USER' and
                  (ora_dict_obj_name = 'SYSTEM' or ora_dict_obj_name = 'SYS')
               THEN
                  RAISE_APPLICATION_ERROR(-20003,
                             'You are not allowed to alter SYSTEM/SYS user.');
               END IF;
          END;
          /

Trigger created.
    使用范例:    
SQL> conn alteruser/oracle
Connected.
SQL> alter user system identified by manager;
alter user system identified by manager
                                *
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-20003: You are not allowed to alter SYSTEM/SYS user.
ORA-06512: at line 5

SQL>  alter user sys identified by manager;
 alter user sys identified by manager
                              *
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-20003: You are not allowed to alter SYSTEM/SYS user.
ORA-06512: at line 5

SQL>
SQL>  alter user dbsnmp identified by dbsnmp;

User altered.

posted on 2013-03-19 00:48  Oracle和MySQL  阅读(578)  评论(0编辑  收藏  举报

导航