Search code examples
oracle-databasefrontendoracle-apex

Is it possible to create/manage a user from inside and Oracle APEX application?


I developed an application in APEX for some engineers in my company to use, but twice a week or so they call my desk asking me to add another user. Is there any way to build a user creation page into an APEX application so that it can be handled entirely by users?


Solution

  • To create a new user outside of the APEX environment you can use PL/SQL. Make sure, that you set the security group to the workspace-id for which the new user will be created. Run this statement as database system user See the code snipped below:

      declare
        l_workspace_id number;
        l_group_id     number;
      begin
        [...]
        l_workspace_id := apex_util.find_security_group_id('Your Workspace Name');
    
        apex_util.set_security_group_id(l_workspace_id);
    
        l_group_id := apex_util.get_group_id('Your User-Group');
    
        apex_util.create_user(p_user_name           => 'Your User-Name',
                              p_email_address       => 'eMail Address',
                              p_first_name          => '...',
                              p_last_name           => '...',
                              p_default_date_format => '...',
                              p_web_password        => '...',
                              p_group_ids           => l_group_id,  
                              p_default_schema      => '...');
    
        [...]
      end;