Create and configure ACL in oracle database, Network Access control list (ACL), smtp_out_server - SMTP outgoing mail server
Create and configure ACL in oracle database, Network Access control list (ACL), smtp_out_server - SMTP outgoing mail server.
Access control lists are created and manipulated
using the DBMS_Network_ACL_Admin and DBMS_Network_ACL_Utility packages. ACLs are
used to control access by users to external network services and resources from
the database through PL/SQL network utility packages including UTL_TCP,
UTL_HTTP, UTL_SMTP, UTL_MAIL and UTL_INADDR.
Follow the below steps to configure ACL.
o Activate UTL_MAIL
SQL> @?/rdbms/admin/utlmail.sql
Package created.
Synonym created.
Package created.
Package body created. Grant succeeded.
Package body created. No errors.
SQL>
o
Find out SMTP mail server ip & port and configure the
database parameter smtp_out_server. Here smtp_out_server's ip is 172.16.20.18
and port is 25.
SQL> show parameter smtp
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
smtp_out_server string
SQL>
SQL> alter system set smtp_out_server='172.16.20.18:25';
System altered.
o Create ACL
In
ACL principals - Users, privileges – right.
dbms_network_acl_admin.create_acl (
acl => 'utl_mail_test.xml',
description => 'Allow mail to be send',
principal => 'FINN',
is_grant => TRUE,
privilege => 'connect'
);
commit;
end;
o Add Privilege
dbms_network_acl_admin.add_privilege (
acl => 'utl_mail_test.xml',
principal => 'FINN',
is_grant => TRUE,
privilege => 'connect'
);
commit;
end;
/
o Assign ACL
dbms_network_acl_admin.assign_acl(
acl => 'utl_mail_test.xml',
host => '172.16.20.18',
lower_port => 25,
upper_port => NULL
);
commit;
end;
/
o If other users need to be added to the ACL list, then run add_ privilege after some changes. Here the other user is ACCT.
begin
acl => 'utl_mail_test.xml',
principal => 'ACCT',
is_grant => TRUE,
privilege => 'connect'
);
commit;
o If other host need to be assign to the same ACL list, then run assign_acl after some changes. Here the other host is '172.16.124.52' and port 7081.
dbms_network_acl_admin.assign_acl(
acl => 'utl_mail_test.xml',
host => '172.16.124.52',
lower_port => 7081,
upper_port => 7081
);
commit;
end;
To Grant Privileges
grant execute on UTL_SMTP to FINN;
grant execute on UTL_MAIL to FINN;
grant execute on UTL_HTTP to FINN;
grant execute on UTL_INADDR to FINN;
grant execute on UTL_SMTP to ACCT;
grant execute on UTL_MAIL to ACCT;
grant execute on UTL_HTTP to ACCT;
o Test the ACL
sys.Utl_Mail.send(sender => 'ora.anup@gmail.com' ,recipients => 'ora.anup@gmail.com'
,subject => 'Testing Mail' ,message => 'This is Testing'
);
SET linesize 135
col HOST for a15
col ACL for a45
SELECT host, lower_port, upper_port, acl FROM dba_network_acls;
The DBA_NETWORK_ACL_PRIVILEGES view displays information about privileges associated with the ACL.
SET linesize 135
col ACL for a45
col PRINCIPAL for a20
col PRIVILEGE for a15
SELECT acl,principal,privilege,is_grant,TO_CHAR(start_date, 'DD-MON-YYYY') AS start_date,TO_CHAR(end_date, 'DD-MON-YYYY') AS end_date FROM dba_network_acl_privileges;
The USER_NETWORK_ACL_PRIVILEGES view displays the current users network ACL settings.
SELECT host, lower_port, upper_port, privilege, status FROM user_network_acl_privileges;
Checking Privileges
col TABLE_NAME for a30;
select grantee , table_name , privilege from dba_tab_privs where table_name = 'UTL_HTTP';
select host, lower_port, upper_port, acl from dba_network_acls where ACL='/sys/acls/utl_mail_test.xml';
Some more articles you
might also be interested in :-
Create and configure ACL in oracle database
The common errors during ACL configuration
Comments
Post a Comment