2013-12-23

Saving user passwords - Oracle 11g


Oracle 11.2

password set in USER$
SEC_CASE_SENSITIVE_LOGON

TRUE
FALSE
password only
non-sensitive
non-sensitive
spare4 only
sensitive
access denied
both set
sensitive
non-sensitive


To save all user passwords
#!/bin/bash
export PWDSQL=user_passwords_${ORACLE_SID}_`date +%Y-%m-%d-%H%M`.sql
sqlplus -S / as sysdba <
set echo off termout off trimspool on feedback off heading off linesize 200 pagesize 0
spool $PWDSQL
select 'alter user '||username||' identified by values '||DBMS_LOB.SUBSTR(REGEXP_SUBSTR(DBMS_METADATA.GET_DDL ('USER',USERNAME), '''.*'''))||';' stmt
from dba_users
where password is null -- to exclude EXTERNAL
and username not in ('XS\$NULL','ANONYMOUS') -- use escape char \ for $ if in shell
order by username;
spool off
EOF

For single user
select 'alter user '||username||' identified by values '||DBMS_LOB.SUBSTR(REGEXP_SUBSTR(DBMS_METADATA.GET_DDL ('USER',USERNAME), '''.*'''))||';' stmt
from dba_users where username like upper('syst%');

No comments:

Post a Comment