Tags

Sandbox OEM servers provide a testbed as part of a well-designed OEM environment, but copying EM security data from one repository to another can be difficult without EM CLI.  This example combines SQL+ and EM CLI to gather data from the existing environment and then reproduced it in the sandbox quickly and completely.

ARGFILE01=/tmp/argfile_create_roles.txt
ARGFILE02=/tmp/argfile_create_users.txt
ARGFILE03=/tmp/argfile_grant_roles.txt

sqlplus -S ${SYSMAN_CONNECT} <<EOF 1>/dev/null
SET ECHO OFF
SET FEEDBACK OFF HEADING OFF LINES 250 PAGES 999

SPOOL ${ARGFILE01}

SELECT 'create_role -name="' || role_name || '" -description="' || description || '"'
FROM sysman.gc_roles
WHERE  role_type= '1';

SPOOL OFF

SPOOL ${ARGFILE02}

SELECT 'create_user -name="' || user_name || '" -desc="' || user_description || '" -password=
||oracle||"  -expired="||true||'"'
FROM sysman.gc_users
WHERE user_name NOT IN ('SYSMAN')
ORDER BY user_name;

SPOOL OFF
SPOOL ${ARGFILE03}

SELECT 'grant_roles -name="' || user_name || '" -roles="' || role_name || '"'
FROM sysman.gc_user_roles;

SPOOL OFF
exit
EOF
emcli login -user=sysman -pass=${CONSOLE_PWD}
emcli argfile ${ARGFILE01}
emcli argfile ${ARGFILE02}
emcli argfile ${ARGFILE03}