8i | 9i | 10g | 11g | 12c | 13c | 18c | Misc | PL/SQL | SQL | RAC | WebLogic | Linux

Home » Articles » 12c » Here

DBMS_CREDENTIAL : Persist Database and OS Credentials in Oracle Database 12c Release 1 (12.1)

In Oracle 12c the credential related sub-programs of the DBMS_SCHEDULER package have been deprecated and replaced by the new DBMS_CREDENTIAL package. From a usage perspective it feels similar.

Related articles.

Create Credentials

Credentials are database objects that hold a username/password pair for authenticating local and remote external jobs. They are created using the CREATE_CREDENTIAL procedure. The procedure also allows you to specify the Windows domain for remote external jobs executed against a Windows server. Credentials are owned by SYS.

CONN test/test

BEGIN
  -- Basic credential.
  DBMS_CREDENTIAL.create_credential(
    credential_name => 'TIM_HALL_CREDENTIAL',
    username        => 'tim_hall',
    password        => 'password');

  -- Credential including Windows domain.
  DBMS_CREDENTIAL.create_credential(
    credential_name => 'TIM_HALL_WIN_CREDENTIAL',
    username        => 'tim_hall',
    password        => 'password',
    windows_domain  => 'localdomain');
END;
/

Information about credentials is displayed using the [DBA|ALL|USER]_CREDENTIALS views.

COLUMN credential_name FORMAT A25
COLUMN username FORMAT A20
COLUMN windows_domain FORMAT A20

SELECT credential_name,
       username,
       windows_domain,
       enabled
FROM   user_credentials
ORDER BY credential_name;

CREDENTIAL_NAME           USERNAME             WINDOWS_DOMAIN       ENABL
------------------------- -------------------- -------------------- -----
TIM_HALL_CREDENTIAL       tim_hall                                  TRUE
TIM_HALL_WIN_CREDENTIAL   tim_hall             LOCALDOMAIN          TRUE

2 rows selected.

SQL>

Enable/Disable Credentials

Credentials are enabled and disabled using the ENABLE_CREDENTIAL and DISABLE_CREDENTIAL procedures respectively.

-- Disable credential.
EXEC DBMS_CREDENTIAL.disable_credential('TIM_HALL_CREDENTIAL');


COLUMN credential_name FORMAT A25
COLUMN username FORMAT A20
COLUMN windows_domain FORMAT A20

SELECT credential_name,
       username,
       windows_domain,
       enabled
FROM   user_credentials
ORDER BY credential_name;

CREDENTIAL_NAME           USERNAME             WINDOWS_DOMAIN       ENABL
------------------------- -------------------- -------------------- -----
TIM_HALL_CREDENTIAL       tim_hall                                  FALSE
TIM_HALL_WIN_CREDENTIAL   tim_hall             LOCALDOMAIN          TRUE

2 rows selected.

SQL>


-- Enable credential.
EXEC DBMS_CREDENTIAL.enable_credential('TIM_HALL_CREDENTIAL');


COLUMN credential_name FORMAT A25
COLUMN username FORMAT A20
COLUMN windows_domain FORMAT A20

SELECT credential_name,
       username,
       windows_domain,
       enabled
FROM   user_credentials
ORDER BY credential_name;

CREDENTIAL_NAME           USERNAME             WINDOWS_DOMAIN       ENABL
------------------------- -------------------- -------------------- -----
TIM_HALL_CREDENTIAL       tim_hall                                  TRUE
TIM_HALL_WIN_CREDENTIAL   tim_hall             LOCALDOMAIN          TRUE

2 rows selected.

SQL>

Update Credentials

The UPDATE_CREDENTIAL procedure allows you to modify attributes of a credential.

BEGIN
  DBMS_CREDENTIAL.update_credential(
    credential_name => 'TIM_HALL_CREDENTIAL',
    attribute       => 'username', 
    value           => 'tim_hall2');

  DBMS_CREDENTIAL.update_credential(
    credential_name => 'TIM_HALL_CREDENTIAL',
    attribute       => 'password', 
    value           => 'password2');
END;
/


COLUMN credential_name FORMAT A25
COLUMN username FORMAT A20
COLUMN windows_domain FORMAT A20

SELECT credential_name,
       username,
       windows_domain,
       enabled
FROM   user_credentials
ORDER BY credential_name;

CREDENTIAL_NAME           USERNAME             WINDOWS_DOMAIN       ENABL
------------------------- -------------------- -------------------- -----
TIM_HALL_CREDENTIAL       tim_hall2                                 TRUE
TIM_HALL_WIN_CREDENTIAL   tim_hall             LOCALDOMAIN          TRUE

2 rows selected.

SQL>

Drop Credentials

Credentials are dropped using the DROP_CREDENTIAL procedure.

EXEC DBMS_CREDENTIAL.drop_credential('TIM_HALL_CREDENTIAL');
EXEC DBMS_CREDENTIAL.drop_credential('TIM_HALL_WIN_CREDENTIAL');

Miscellaneous

For backwards compatibility, it is not mandatory to specify credentials for local external jobs. If no credentials are set the default users are as follows.

Oracle recommend using credentials for all local and remote external jobs as the default values may be deprecated in future.

The operating system user specified by the credential must have the necessary privileges to perform the required action. On Windows platforms this must include the "Log on as batch job" security policy, applied using the "Local Security Policies" dialog.

For more information see:

Hope this helps. Regards Tim...

Back to the Top.