create apex user via plsql script - oracle-apex

Run script from https://www.talkapex.com/2012/08/how-to-create-apex-session-in-plsql and get error
[Error] Execution (1: 1): ORA-20987: APEX - Application ID and current security group ID are not consistent. - Contact your application administrator.
Details about this incident are available via debug id "78243".
ORA-06512: at "APEX_190100.WWV_FLOW_ERROR", line 1381
ORA-06512: at "APEX_190100.WWV_FLOW_ERROR", line 1416
ORA-06512: at "APEX_190100.WWV_FLOW_CUSTOM_AUTH_STD", line 724
ORA-06512: at "APEX_190100.WWV_FLOW_CUSTOM_AUTH_STD", line 588
ORA-06512: at "APEX_190100.HTMLDB_CUSTOM_AUTH", line 260
ORA-06512: at "USER.SP_CREATE_APEX_SESSION", line 30
ORA-06512: at line 2
error raise from
apex_custom_auth.post_login(
p_uname => p_app_user,
p_session_id => APEX_CUSTOM_AUTH.GET_NEXT_SESSION_ID,
p_app_page => apex_application.g_flow_id||':'||p_app_page_id);
how to properly create a user in need wokrspace? Apex version 19.1
and create user
BEGIN
FOR C1 IN (SELECT WORKSPACE_ID
FROM APEX_APPLICATIONS
WHERE APPLICATION_ID = 4050)
LOOP
APEX_UTIL.SET_SECURITY_GROUP_ID (
P_SECURITY_GROUP_ID => C1.WORKSPACE_ID);
END LOOP;
APEX_UTIL.CREATE_USER (
P_USER_NAME => 'BOB',
P_EMAIL_ADDRESS => 'bob#bob.com',
P_DEFAULT_SCHEMA => 'MY_SPACE',
P_ALLOW_ACCESS_TO_SCHEMAS => 'MY_SPACE',
P_WEB_PASSWORD => 'change_me',
P_DEVELOPER_PRIVS =>
'ADMIN:CREATE:DATA_LOADER:EDIT:HELP:MONITOR:SQL'); -- workspace administrator
COMMIT;
END;
i have same error
[Error] Execution (2: 1): ORA-20987: APEX - Security Group ID (your workspace identity) is invalid. - Contact your application administrator.
declare
l_workspace_id number;
begin
l_workspace_id := apex_util.find_security_group_id (p_workspace => 'INTERNAL');
apex_util.set_security_group_id (p_security_group_id => l_workspace_id);
apex_util.create_user(
p_user_name => 'NEWUSER1',
p_web_password => 'secret99');
commit;
end;
Error at line 1 ORA-20001: Package variable g_security_group_id must
be set. ORA-06512: at "APEX_190100.WWV_FLOW_API", line 1828 ORA-06512:
at "APEX_190100.WWV_FLOW_API", line 1863 ORA-06512: at
"APEX_190100.WWV_FLOW_FND_USER_INT", line 1977 ORA-06512: at
"APEX_190100.HTMLDB_UTIL", line 1452 ORA-06512: at line 6
SELECT WORKSPACE,WORKSPACE_DISPLAY_NAME, OWNER, APPLICATION_GROUP_ID FROM APEX_APPLICATIONS WHERE WORKSPACE = 'INTERNAL' AND APPLICATION_ID = 4050;
INTERNAL >INTERNAL
APEX_190100
9.1051E+16
1 row selected.

Ok, now this makes more sense. You're trying to create a user but it fails when trying to create a session prior to creating the user. You don't need a session to create a user, you just need the security group to be set. This can be done using APEX_UTIL.SET_SECURITY_GROUP_ID. I executed this code in my environment, connected via sqldeveloper:
DECLARE
l_workspace_id number;
BEGIN
l_workspace_id := apex_util.find_security_group_id (p_workspace => '<myworkspacename>');
apex_util.set_security_group_id (p_security_group_id => l_workspace_id);
APEX_UTIL.CREATE_USER(
p_user_name => 'NEWUSER1',
p_web_password => 'secret99');
COMMIT;
END;
/
and the user was created without errors.

Related

Amazon RDS log file errors

I'm attempting to connect to my rds database inside of AWS via my code using pymysql using the following code (note that my endpoint and password variables will be replaced for the sake of my own privacy):
import pymysql
ENDPOINT = "*******"
PORT = "3306"
USER = "admin"
PASSWORD = "*******"
DBNAME = "appdb2"
print("INITIALIZING DATABASE")
conn = pymysql.connect(host=ENDPOINT, user=USER, password = PASSWORD, database = DBNAME)
cur = conn.cursor()
#Creates curser to interact with database
try:
cur.execute("DROP TABLE userdetails;")
print("table deleted")
#If no database, create table with inserts and commit and execute
except Exception as e:
print("cannot delete table")
cur.execute("CREATE TABLE userdetails(email VARCHAR(20), password VARCHAR(20), description VARCHAR(50), imagelocation VARCHAR(50));")
print("table created")
cur.execute("INSERT INTO userdetails(email, password, description, imagelocation) VALUES('alex.hamilton1996#gmail.com', 'password', 'this is a desc', 'Default.png');")
print("Insert Success")
cur.execute("INSERT INTO userdetails(email, password, description, imagelocation) VALUES('alex.hamilton19961#gmail.com', 'password', 'this is a desc', 'Default.png');")
print("Insert Success")
cur.execute("INSERT INTO userdetails(email, password, description, imagelocation) VALUES('alex.hamilton19962#gmail.com', 'password', 'this is a desc', 'Default.png');")
print("Insert Success")
cur.execute("INSERT INTO userdetails(email, password, description, imagelocation) VALUES('alex.hamilton19963#gmail.com', 'password', 'this is a desc', 'Default.png');")
print("Insert Success")
cur.execute("SELECT * FROM userdetails;")
I am left with a long error message as follows whenever I run this:
$ C:/Users/alexh/AppData/Local/Programs/Python/Python39/python.exe "c:/Users/alexh/Dropbox/PC/Desktop/Cloud Computing/testcode.py"
INITIALIZING DATABASE
Traceback (most recent call last):
File "C:\Users\alexh\AppData\Local\Programs\Python\Python39\lib\site-packages\pymysql\connections.py", line 613, in connect
sock = socket.create_connection(
File "C:\Users\alexh\AppData\Local\Programs\Python\Python39\lib\socket.py", line 843, in create_connection
raise err
File "C:\Users\alexh\AppData\Local\Programs\Python\Python39\lib\socket.py", line 831, in create_connection
sock.connect(sa)
socket.timeout: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\alexh\Dropbox\PC\Desktop\Cloud Computing\testcode.py", line 10, in <module>
conn = pymysql.connect(host=ENDPOINT, user=USER, password = PASSWORD, database = DBNAME)
File "C:\Users\alexh\AppData\Local\Programs\Python\Python39\lib\site-packages\pymysql\connections.py", line 353, in __init__
self.connect()
File "C:\Users\alexh\AppData\Local\Programs\Python\Python39\lib\site-packages\pymysql\connections.py", line 664, in connect
raise exc
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'appdb2.c7oob6smafaa.us-east-2.rds.amazonaws.com' (timed out)")
Whenever I go to the my RDS logs in AWS, I get the following error messages:
2022-08-03T16:13:01.357351Z 0 [Warning] [MY-011068] [Server] The syntax 'log_slave_updates' is deprecated and will be removed in a future release. Please use log_replica_updates instead.
2022-08-03T16:13:01.357380Z 0 [Warning] [MY-011069] [Server] The syntax '--master-info-repository' is deprecated and will be removed in a future release.
2022-08-03T16:13:01.357393Z 0 [Warning] [MY-011069] [Server] The syntax '--master-info-repository' is deprecated and will be removed in a future release.
2022-08-03T16:13:01.357455Z 0 [Warning] [MY-011069] [Server] The syntax '--relay-log-info-file' is deprecated and will be removed in a future release.
2022-08-03T16:13:01.357462Z 0 [Warning] [MY-011069] [Server] The syntax '--relay-log-info-repository' is deprecated and will be removed in a future release.
2022-08-03T16:13:01.357491Z 0 [Warning] [MY-011068] [Server] The syntax 'skip_slave_start' is deprecated and will be removed in a future release. Please use skip_replica_start instead.
2022-08-03T16:13:01.357498Z 0 [Warning] [MY-011068] [Server] The syntax 'slave_exec_mode' is deprecated and will be removed in a future release. Please use replica_exec_mode instead.
2022-08-03T16:13:01.357506Z 0 [Warning] [MY-011068] [Server] The syntax 'slave_load_tmpdir' is deprecated and will be removed in a future release. Please use replica_load_tmpdir instead.
2022-08-03T16:13:01.358795Z 0 [Warning] [MY-010101] [Server] Insecure configuration for --secure-file-priv: Location is accessible to all OS users. Consider choosing a different directory.
2022-08-03T16:13:01.358834Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2022-08-03T16:13:01.359306Z 0 [System] [MY-010116] [Server] /rdsdbbin/mysql/bin/mysqld (mysqld 8.0.28) starting as process 722
2022-08-03T16:13:01.445821Z 0 [Warning] [MY-010161] [Server] You need to use --log-bin to make --log-replica-updates work.
2022-08-03T16:13:01.513243Z 0 [Warning] [MY-010075] [Server] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 25bc428b-1347-11ed-9128-02b016500430.
2022-08-03T16:13:01.553323Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-08-03T16:13:01.581857Z 1 [Warning] [MY-012191] [InnoDB] Scan path '/rdsdbdata/db/innodb' is ignored because it is a sub-directory of '/rdsdbdata/db/
2022-08-03T16:13:02.047699Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-08-03T16:13:02.330046Z 0 [Warning] [MY-010161] [Server] You need to use --log-bin to make --binlog-expire-logs-seconds work.
2022-08-03T16:13:02.337052Z 0 [Warning] [MY-013414] [Server] Server SSL certificate doesn't verify: unable to get issuer certificate
2022-08-03T16:13:02.337158Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2022-08-03T16:13:02.394864Z 0 [System] [MY-010931] [Server] /rdsdbbin/mysql/bin/mysqld: ready for connections. Version: '8.0.28' socket: '/tmp/mysql.sock' port: 3306 Source distribution.
Does anybody have any advice as to how I can fix this issue given the feedback that these logs gave me? Thank you.

in Oracle Autonomous database try to create an workspace in the plsql program by using the apex_util.create_user. but failed

APEX_UTIL.SET_SECURITY_GROUP_ID( APEX_UTIL.FIND_SECURITY_GROUP_ID( p_workspace => 'teacher' ));
apex_util.create_user(
p_user_name => 'teacher',
p_web_password => 'ChangeMe#1234',
p_developer_privs => 'ADMIN:CREATE:DATA_LOADER:EDIT:HELP:MONITOR:SQL',
p_email_address => 'test1#example.com',
p_default_schema => 'teacher',
p_change_password_on_first_use => 'N' );
end;
Error report -
ORA-20001: Package variable g_security_group_id must be set.
ORA-06512: at "APEX_210100.WWV_FLOW_API", line 485
ORA-06512: at "APEX_210100.WWV_FLOW_API", line 520
ORA-06512: at "APEX_210100.WWV_FLOW_FND_USER_INT", line 1731
ORA-06512: at "APEX_210100.HTMLDB_UTIL", line enter code here 1245
ORA-06512: at line 5
does the Oracle Autonomous database allow developer to create apex workspace via the programming method?
any API available?
Does the OCI for Java SDK support the creation of APEX?
To add workspaces to your APEX instance, please use the ADD_WORKSPACE procedure.
Example:
BEGIN
APEX_INSTANCE_ADMIN.ADD_WORKSPACE (
p_workspace_id => 8675309,
p_workspace => 'MY_WORKSPACE',
p_primary_schema => 'SCOTT',
p_additional_schemas => 'HR:OE' );
END;
To create APEX users on Autonomous Database, please note:
Application Express Administration Services and the Oracle Application
Express development environment on Autonomous Database use Database
Accounts authentication. This authentication method uses the database
account user name and password to authenticate users.

scandir(/var/app/current/protected/modules): Failed to open directory: No such file or directory

I have tried to host humhub which is an yii2 open source social media on aws elastic beanstalk but when I open the site I get an error exception
Can anyone tell me how to fix it please?
This is the error
PHP Warning – yii\base\ErrorException
scandir(/var/app/current/protected/modules): Failed to open directory: No such file or directory
in /var/app/current/protected/humhub/components/bootstrap/ModuleAutoLoader.php at line 50
yii\base\ErrorHandler::handleError(2, 'scandir(/var/app/current/protect...', '/var/app/current/protected/humhu...', 50)
in /var/app/current/protected/humhub/components/bootstrap/ModuleAutoLoader.php at line 50 – scandir('/var/app/current/protected/modul...')
in /var/app/current/protected/humhub/components/bootstrap/ModuleAutoLoader.php at line 32 – humhub\components\bootstrap\ModuleAutoLoader::locateModules()
in /var/app/current/protected/vendor/yiisoft/yii2/base/Application.php at line 327 – humhub\components\bootstrap\ModuleAutoLoader::bootstrap(humhub\components\Application)
in /var/app/current/protected/vendor/yiisoft/yii2/web/Application.php at line 69 – yii\base\Application::bootstrap()
in /var/app/current/protected/humhub/components/Application.php at line 46 – yii\web\Application::bootstrap()
in /var/app/current/protected/vendor/yiisoft/yii2/base/Application.php at line 273 – humhub\components\Application::bootstrap()
in /var/app/current/protected/vendor/yiisoft/yii2/base/BaseObject.php at line 109 – yii\base\Application::init()
in /var/app/current/protected/vendor/yiisoft/yii2/base/Application.php at line 206 – yii\base\BaseObject::__construct(['name' => 'HumHub', 'version' => '1.5.1', 'bootstrap' => ['log', 'humhub\components\bootstrap\Modu...', 'queue', 'humhub\modules\ui\view\bootstrap...', ...], 'sourceLanguage' => 'en', ...])
in /var/app/current/index.php at line 25 – yii\base\Application::__construct(['name' => 'HumHub', 'version' => '1.5.1', 'bootstrap' => ['log', 'humhub\components\bootstrap\Modu...', 'queue', 'humhub\modules\ui\view\bootstrap...', ...], 'sourceLanguage' => 'en', ...])

Chef, cannot find template

I am trying to use chef with aws opsworks.
however it doesn't seem to be loading my template.
Here is the part of the recipe concerned which is in /api/recipes/configure.rb
# write out our applications site configurations
template "/etc/httpd/sites-available/#{application}.conf" do
source 'site-config.erb'
owner 'root'
group 'root'
mode 0644
variables(
:docroot => "#{deploy[:deploy_to]}/public"
)
end
Here is the stack trace
[2014-04-15T05:08:03+00:00] INFO: Processing template[/etc/httpd/sites-available/testing_app.conf] action create (api::configure line 33)
================================================================================
Error executing action `create` on resource 'template[/etc/httpd/sites-available/testing_app.conf]'
================================================================================
Chef::Exceptions::FileNotFound
------------------------------
Cookbook 'api' (0.1.0) does not contain a file at any of these locations:
templates/amazon-2013.09/site-config.erb
templates/amazon/site-config.erb
templates/default/site-config.erb
Resource Declaration:
---------------------
# In /var/lib/aws/opsworks/cache/cookbooks/api/recipes/configure.rb
33: template "/etc/httpd/sites-available/#{application}.conf" do
34: source 'site-config.erb'
35: owner 'root'
36: group 'root'
37: mode 0644
38: variables(
39: :docroot => "#{deploy[:deploy_to]}/public"
40: )
41: end
42:
Compiled Resource:
------------------
# Declared in /var/lib/aws/opsworks/cache/cookbooks/api/recipes/configure.rb:33:in `block in from_file'
template("/etc/httpd/sites-available/testing_app.conf") do
provider Chef::Provider::Template
action "create"
retries 0
retry_delay 2
path "/etc/httpd/sites-available/testing_app.conf"
backup 5
atomic_update true
source "site-config.erb"
variables {:docroot=>"/srv/www/testing_app/public"}
cookbook_name "api"
recipe_name "configure"
owner "root"
group "root"
mode 420
end
[2014-04-15T05:08:03+00:00] INFO: Running queued delayed notifications before re-raising exception
[2014-04-15T05:08:03+00:00] ERROR: Running exception handlers
[2014-04-15T05:08:03+00:00] ERROR: Exception handlers complete
[2014-04-15T05:08:03+00:00] FATAL: Stacktrace dumped to /var/lib/aws/opsworks/cache/chef-stacktrace.out
[2014-04-15T05:08:03+00:00] ERROR: template[/etc/httpd/sites-available/testing_app.conf] (api::configure line 33) had an error: Chef::Exceptions::FileNotFound: Cookbook 'api' (0.1.0) does not contain a file at any of these locations:
templates/amazon-2013.09/site-config.erb
templates/amazon/site-config.erb
templates/default/site-config.erb
[2014-04-15T05:08:04+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
And here is my directory structure
You will need to put the template into one of the following directories api/templates/default api/templates/amazon or api/templates/amazon-2013.09. If you want the same template files to work on any platform, then put the templates in the api/templates/default directory.
Check out http://docs.chef.io/templates.html#file-specificity for more details on where you might want to place your templates.

Accessing web service in oracle 10g pl/sql procedures

I’m using soap_api method for accessing web services in oracle. When I create add_numbers function and I execute add_numbers function then Function doesn’t execute.
fires following error when calling web service in select statement
select add_numbers(2,5) from dual
error is
ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP",line 1029
ORA-12541: TNS:no listener
ORA-06512: at "dbtest.SOAP_API",line 144
ORA-06512: at "dbtest.ADD_NUMBERS", line 34 FROM!
I’m using this function and soap_api methods from this link. taken example from
http://www.oracle-base.com/articles/9i/consuming-web-services-9i.php#Top
Function for calling web services.
CREATE OR REPLACE FUNCTION add_numbers (p_int_1 IN NUMBER, p_int_2 IN NUMBER) RETURN NUMBER AS
l_request soap_api.t_request;
l_response soap_api.t_response;
l_return VARCHAR2(32767);
l_url VARCHAR2(32767);
l_namespace VARCHAR2(32767);
l_method VARCHAR2(32767);
l_soap_action VARCHAR2(32767);
l_result_name VARCHAR2(32767);
BEGIN
l_url := 'http://192.168.0.75:9001/LicWebService.asmx';
l_namespace := 'xmlns="http://192.168.0.75:9001/"';
l_method := 'AddNum';
l_soap_action := 'http://192.168.0.75:9001/AddNum';
l_result_name := 'return';
l_request := soap_api.new_request(p_method => l_method, p_namespace=> l_namespace);
soap_api.add_parameter(p_request => l_request,p_name => 'int1',p_type => 'xsd:integer',p_value => p_int_1);
soap_api.add_parameter(p_request => l_request,p_name=> 'int2', p_type=> 'xsd:integer',p_value => p_int_2);
l_response := soap_api.invoke(p_request => l_request, p_url=> l_url, p_action => l_soap_action);
l_return := soap_api.get_return_value(p_response => l_response,p_name=> l_result_name, p_namespace => NULL);
END;
Kindly suggest me where i am making mistake.
Either your TNS is not set up properly or the TNS service is not running. This is the reason why the UTL_HTTP api isn't working (which is used by SOAP_API).
Follow this link to troubleshoot and resolve this.