ORACLE APEX_MAIL - oracle

I am trying to send mail with apex_mail
Here is my configuration , but i did receive any mails
Is there something missing?
Thanks

Execute this code as sysdba to grant permissions for your DB User to connect to smtp server:
begin
dbms_network_acl_admin.create_acl
(
acl => 'mail.xml',
description => 'Access to smtp server',
principal => 'DBUser', -- DB Schema (grantee)
is_grant => true,
privilege => 'connect',
start_date => null,
end_date => null
);
dbms_network_acl_admin.assign_acl(
acl => 'mail.xml',
host => 'mail.muncipaldata.com', -- SMTP host
lower_port => 1025,
upper_port => 1025
);
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(
acl => 'mail.xml',
principal => 'DBUser', -- DB Schema (grantee)
is_grant => true,
privilege => 'resolve',
start_date => null,
end_date => null
);
end;

Related

ACL for Sending e-Mail with APEX Oracle 11.2

I'm trying to send e-Mail as a simple Send e-Mail process with Oracle APEX 11.2, and I can't figure out how the correct ACL has to be set. I tried this, but no success, still getting: ORA-24247: network access denied by access control list (ACL). What am I doing wrong?
SELECT * FROM dba_network_acl_privileges shows that all rules are granted and also select * from dba_network_acls shows both rules.
Thanks in Advance!
BEGIN
DBMS_NETWORK_ACL_ADMIN.DROP_ACL (acl => 'send_mail.xml' );
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL('send_mail.xml','Allow mail to be send', 'APEX_050100', TRUE, 'connect');
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE('send_mail.xml','APEX_050100',TRUE, 'connect');
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE('send_mail.xml','APEX_050100',TRUE, 'resolve');
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL (acl => 'send_mail.xml',host => '*',lower_port => null, upper_port => null);
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL (acl => 'send_mail.xml',host => 'smtp.google.com',lower_port => null, upper_port => null);
commit;
END;
BEGIN
DBMS_NETWORK_ACL_ADMIN.DROP_ACL (acl => 'utl_smtp.xml' );
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL('utl_smtp.xml','Allow mail to be send', 'APEX_050100', TRUE, 'connect');
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE('utl_smtp.xml','APEX_050100',TRUE, 'connect');
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE('utl_smtp.xml','APEX_050100',TRUE, 'resolve');
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL (acl => 'utl_smtp.xml',host => '*',lower_port => null, upper_port => null);
END;
This is how I do it.
-- Drop ACL ====================================================================
BEGIN
DBMS_NETWORK_ACL_ADMIN.drop_acl (acl => 'mydba.xml');
END;
/
-- Create ACL ==================================================================
BEGIN
DBMS_NETWORK_ACL_ADMIN.create_acl (
acl => 'mydba.xml',
description => 'SMTP, MAIL, HTTP Access',
principal => 'LITTLEFOOT',
is_grant => TRUE,
privilege => 'connect',
start_date => NULL,
end_date => NULL);
END;
/
-- Assign ACL ==================================================================
BEGIN
DBMS_NETWORK_ACL_ADMIN.assign_acl (acl => 'mydba.xml',
HOST => '*',
lower_port => NULL,
upper_port => NULL);
END;
/
-- Add privilege ===============================================================
BEGIN
-- LITTLEFOOT
DBMS_NETWORK_ACL_ADMIN.add_privilege (acl => 'mydba.xml',
principal => 'LITTLEFOOT',
is_grant => TRUE,
privilege => 'connect',
start_date => NULL,
end_date => NULL);
DBMS_NETWORK_ACL_ADMIN.add_privilege (acl => 'mydba.xml',
principal => 'LITTLEFOOT',
is_grant => TRUE,
privilege => 'resolve',
start_date => NULL,
end_date => NULL);
END;
/
COMMIT;
When new users require privileges, I just copy/paste LITTLEFOOT's data from the "Add privilege" procedure and change principal's name (currently, there are dozen of users in my script).

ORA-24247: network access denied by access control list (ACL)?

I would like to connect to a certain URL from PL/SQL:
I did the following steps
Created an ACL
Granted both connect and resolve privileges to my schema
Assigned the URL to the ACL
BEGIN
-- Create new acl
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(acl => 'NiceACL', description => 'My ACL', principal => 'JOHN',is_grant => true, privilege => 'connect');
-- Connect privilege
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(acl => 'NiceACL', principal => 'JOHN', is_grant => true, privilege => 'connect');
-- Resolve privilege
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(acl => 'NiceACL', principal => 'JOHN', is_grant => true, privilege => 'resolve');
-- Assign host
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(acl => 'NiceACL', host => 'domain.com');
COMMIT;
END;
After these steps, I run the following query and I can see the ACL Created and granted to the schema, and the host associated to the ACL
SELECT acl,
u.username,
host,
DECODE(DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE_ACLID(aclid, u.username, 'connect'), 1, 'GRANTED', 0, 'DENIED', null) conn_privilege,
DECODE(DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE_ACLID(aclid, u.username, 'resolve'), 1, 'GRANTED', 0, 'DENIED', null) res_privilege
FROM
dba_network_acls a,
dba_users u
where
u.username = 'JOHN';
But When opening a connect (via the schema John) I'm getting the error : ORA-24247: network access denied by access control list (ACL)
UTL_TCP.OPEN_CONNECTION(REMOTE_HOST => 'domain.com', REMOTE_PORT => 8080, TX_TIMEOUT => 10);
Can anyone help please ?
Thanks

Oracle : Network access denied by access control list

I'm running Oracle 18c XE
I'm trying to connect to the following URL :
URL := 'https://domain.example.com/api'
apex_web_service.make_rest_request(p_url => URL, p_http_method => GetOrPost, p_body => RequestBody);
I'm getting the error :
ORA-29273: HTTP request failed
ORA-06512: at "APEX_190200.WWV_FLOW_WEB_SERVICES", line 1283
ORA-06512: at "APEX_190200.WWV_FLOW_WEB_SERVICES", line 924
ORA-24247: network access denied by access control list (ACL)
I tried to create an ACL for that
exec DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(acl => 'MyACL.xml', description => 'MyACL', principal => 'Schema', is_grant => true, privilege => 'connect');
exec DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(acl => 'MyACL.xml', principal => 'Schema', is_grant => true, privilege => 'resolve');
exec DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(acl => 'MyACL.xml', host => '*', lower_port => 443, upper_port => 443);
tried several assigns :
exec DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(acl => 'MyACL.xml', host => 'domain.example.com/api', lower_port => 443, upper_port => 443);
exec DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(acl => 'MyACL.xml', host => 'domain.example.com/api');
None is working.
Can someone help please ?
Thanks.
Cheers

Ldap query for Authentication based on AD security group

I've seen a couple of posts here on this topic, but I can't manage to authenticate by users in a group. If I point the path to where a user is, authentication is successful. It's like it "cannot read" inside the group. I'm must be missing something.
my configs are:
$GLOBALS['ldapdsn'] = array(
// primary server MS AD Server
// port 636 is ldaps and port 389 is ldap
array(
'url' => '172.25.20.3',
'port' => '389',
'version' => '3',
'referral' => 'false',
'basedn' => 'CN=RedcapUsers,OU=RedCap,OU=Srv,DC=mydomain,DC=com',
'binddn' => 'CN=RedcapLdap,OU=RedCap,OU=Srv,DC=mydomain,DC=com',
'bindpw' => 'mypass',
'attributes' => array('sAMAccountName'),
'userattr' => 'sAMAccountName',
'userfilter' => '(objectClass=user)',
), //
RedcapUsers is the AD group.
Binding works fine.
I'm pretty new in code writing.
Filter the AD group ( See last line of code) and issue is resolved !
'url' => 'Active Directory ip',
'port' => '636',
'version' => '3',
'referral' => 'false',
'basedn' => 'OU=Users,DC=Ali,DC=local', // Must be exact OU where users are
'binddn' => 'CN=service_redcap,OU=Users,DC=Ali,DC=local', //-- User who give access to AD
'bindpw' => 'myPassword', // ---Password to above user
'attributes' => array('samAccountName'),
'userattr' => 'samAccountName',
'userfilter' => '(memberOf=CN=REDCAP_GROUP,DC=Ali,DC=local)' //-- Users in this group will loging to Redcap

How do I send e-mails through Oracle DBMS_SCHEDULER?

I'm having difficulty sending email notifications through DBMS_SCHEDULER.
I've gone through instructions here on adding email notifications and here on configuring the mail server but I still don't get any e-mails sent. I'm using the same mail server settings on UTL_MAIL (to send mail using procedures) and Oracle Enterprise Manager (To get backup and availability email and they work fine.) I would rather not use UTL_MAIL instead as it doesn't offer the simplicity and flexibility I'm hoping to achieve with scheduler emails.
Below we have what server settings I've configured and how I'm trying to create a job that will send notifications.
/*Settings*/
exec dbms_scheduler.set_scheduler_attribute('email_server','xxx');
exec dbms_scheduler.set_scheduler_attribute('email_sender','Scheduler#domain.com');
/* Dont think this is needed but added anyway, this allows UTL_MAIL to work*/
alter system set smtp_out_server = 'xxx';
begin
dbms_network_acl_admin.create_acl (
acl => 'dbms_scheduler.xml',
description => 'Allow mail to be send',
principal => 'SCHEMA',
is_grant => TRUE,
privilege => 'connect'
);
commit;
end;
begin
dbms_network_acl_admin.add_privilege (
acl => 'dbms_scheduler.xml',
principal => 'SCHEMA',
is_grant => TRUE,
privilege => 'resolve'
);
commit;
end;
begin
dbms_network_acl_admin.assign_acl(
acl => 'dbms_scheduler.xml',
host => 'xxx'
);
commit;
end;
/*Create a quick, simple job*/
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => '"SCHEMA"."EMAIL_TEST"',
job_type => 'STORED_PROCEDURE',
job_action => 'SCHEMA.DO_MOD',
number_of_arguments => 0,
start_date => NULL,
repeat_interval => NULL,
end_date => NULL,
enabled => FALSE,
auto_drop => FALSE,
comments => '');
DBMS_SCHEDULER.SET_ATTRIBUTE(
name => '"SCHEMA"."EMAIL_TEST"',
attribute => 'restartable', value => TRUE);
DBMS_SCHEDULER.SET_ATTRIBUTE(
name => '"SCHEMA"."EMAIL_TEST"',
attribute => 'logging_level', value => DBMS_SCHEDULER.LOGGING_RUNS);
DBMS_SCHEDULER.SET_ATTRIBUTE(
name => '"SCHEMA"."EMAIL_TEST"',
attribute => 'raise_events', value => '511');
DBMS_SCHEDULER.ADD_JOB_EMAIL_NOTIFICATION (
job_name => '"SCHEMA"."EMAIL_TEST"',
recipients => 'user#xxx',
sender => 'oracle#xxx',
subject => 'Oracle Scheduler Job Notification - %job_owner%.%job_name%.%job_subname% %event_type%',
body => 'Job: %job_owner%.%job_name%.%job_subname%
Event: %event_type%
Date: %event_timestamp%
Log id: %log_id%
Job class: %job_class_name%
Run count: %run_count%
Failure count: %failure_count%
Retry count: %retry_count%
Error code: %error_code
%Error message: %error_message%',
events => 'job_started, job_broken, job_chain_stalled, job_completed, job_disabled, job_failed, job_over_max_dur, job_run_completed, job_sch_lim_reached, job_stopped, job_succeeded',
filter_condition => NULL
);
DBMS_SCHEDULER.enable(
name => '"SCHEMA"."EMAIL_TEST"');
END;
This code all completes successfully but I get no emails. I can also see the entries in user_scheduler_notifications but receive nothing.

Resources