Book Image

Oracle APEX Best Practices

Book Image

Oracle APEX Best Practices

Overview of this book

Have you ever wanted to create real-world database applications? In this book you're not only getting APEX best practices, but will also take into account the total environment of an APEX application and benefit from it."Oracle APEX Best Practices" will guide you through the development of real-world applications. It will give you a broader view of APEX. The various aspects include setting up APEX environment, testing and debugging, security, and getting the best out of SQL and PL/SQL.In six distinct chapters you will learn about different features of Oracle APEX as well as SQL and PL/SQL.Do you maximize the capabilities of Oracle APEX? Do you use all the power that SQL and PL/SQL have to offer? Do you want to learn how to build a secure, fully functional application? Then this is the book you'll need. "Oracle APEX: Best Practices" is where practical development begins!
Table of Contents (14 chapters)
Oracle APEX Best Practices
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a second administrator


When installing APEX, by default the workspace Internal with the administrator user Admin is created. Some users know more than the average end user. Also, developers have more knowledge than the average user. Imagine that such users try to log in to either the APEX Administration Services or the normal login page with the workspace Internal and administrator Admin, and consequently use the wrong password. As a consequence, the Admin account would be locked after a number of login attempts. This is a very annoying situation, especially when it happens often. Big companies and APEX Hosting companies with many workspaces and a lot of anonymous users or developers may suffer from this. Fortunately there is an easy solution, creating a second administrator account.

Login attempt in workspace Internal as Admin

If the account is already locked, we have to unlock it first. This can be easily done by running the apxchpwd.sql script, which can be found in the main Apex directory of the unzipped installation file of APEX:

  1. Start SQL*Plus and connect as sys with the sysdba role.

  2. Run the script by entering @apxchpwd.sql.

  3. Follow the instructions and enter a new password.

Now we are ready to create a second administrator account. This can be done in two ways, using the web interface or the command line.

APEX web interface

Follow these steps to create a new administrator, using the browser.

First, we need to log in to the APEX Administrator Services at http://server:port/apex/. Log in to the workspace Internal, with the administrator credentials.

After logging in, perform the following steps:

  1. Go to Manage Workspaces.

  2. Select Existing Workspaces.

  3. You can also select the edit icon of the workspace Internal to inspect the settings. You cannot change them. Select Cancel to return to the previous screen.

  4. Select the workspace Internal by clicking on the name.

  5. Select Manage Users. Here you can see the user Admin.

  6. You can also select the user Admin to change the password. Other settings cannot be changed. Select Cancel or Apply Changes to return to the previous screen.

  7. Select Create User. Make sure that Internal is selected in the Workspace field and APEX_xxxxxx is selected in Default Schema, and that the new user is an administrator. xxxxxx has to match your APEX scheme version in the database, for instance, APEX_040100.

  8. Click on Create to finish.

    Settings for the new administrator

Command line

When we still have access, we can use the web interface of APEX. If not we can use the command line:

  1. Start SQL*Plus and connect as SYS with the SYSDBA role.

  2. Unlock the APEX_xxxxxx account by issuing the following command:

    alter user APEX_xxxxxx account unlock;
    
  3. Connect to the APEX_xxxxxx account. If you don't remember your password, you can just reset it, without impacting the APEX instance.

  4. Execute the following (use your own username, e-mail, and password):

    BEGIN
      wwv_flow_api.set_security_group_id(p_security_group_id=>10); 
      wwv_flow_fnd_user_api.create_fnd_user( 
        p_user_name     => 'second_admin', 
        p_email_address => '[email protected]',
        p_web_password  => 'second_admin_password') ; 
    END;
    /
    COMMIT
    /
  5. The new administrator is created. Connect again as SYS with the SYSDBA role and lock the account again with the following command:

    alter user APEX_xxxxxx account lock;
    
  6. Now you can log in to the Internal workspace with your newly created account and you'll be asked to change your password.

Other accounts

When an administrator of a developer workspace loses his/her password or has a locked account, you can bring that account back to life by following these steps:

  1. Log in to the APEX Administrator Services.

  2. Go to Manage Workspace.

  3. Select Existing Workspaces.

  4. Select the workspace.

  5. Select Manage Users.

  6. Select the user, change the password, and unlock the user.

A developer or an APEX end user account can be managed by the administrator of the workspace from the workspace itself. Follow these steps to do so:

  1. Log in to the workspace.

  2. Go to Administration.

  3. Select the user, change the password, and unlock the user.