--1.创建访问控制列表(ACLemail_server_permissions),
BEGIN
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL (
acl => 'email_server_permissions.xml',
description => 'Enables network permissions for the e-mail server',
principal => 'NC633', --此为将来要进行操作的用户
is_grant => TRUE,
privilege => 'connect');
END;
/ --2. 将此 ACL 与邮件服务器相关联,
BEGIN
DBMS_NETWORK_ACL_ADMIN.assign_acl (
acl => 'email_server_permissions.xml',
host => '10.10.0.200', --SMTP服务器地址
lower_port => 25,
upper_port => 25);
COMMIT;
END;
/ --3.创建访问控制列表(ACL)network_services,
BEGIN
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL (
acl => 'network_services.xml',
description => 'Enables network permissions for the e-mail server',
principal => 'NC633', --此为将来要进行操作的用户
is_grant => TRUE,
privilege => 'connect');
END;
/ --4. 将此 ACL 与邮件服务器相关联,
BEGIN
DBMS_NETWORK_ACL_ADMIN.assign_acl (
acl => 'network_services.xml',
host => '*', --SMTP服务器地址
lower_port => NULL,
upper_port => NULL);
COMMIT;
END;
/ ----查询
SELECT host, lower_port, upper_port, acl FROM dba_network_acls;
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;
删除ACL方法
--删除ACL
BEGIN
DBMS_NETWORK_ACL_ADMIN.drop_acl(acl => 'network_services.xml');
COMMIT;
END;
/