Lab 10 — User, Role, Profile and Audit Inspection (Read-only)
🧠 ภาพจำก่อนอ่าน: 🧪 Lab → 👤 Identity → 🔑 Access → 🛡️ Controls → 🧹 Cleanup
🎨 Visual Guide ของวิชานี้ — ภาพช่วยจำ ไม่แทนคำสั่งและเนื้อหาจริง
Status: Original Thai companion lab, static reviewed, NOT EXECUTED. Does not reproduce official Oracle Activity Guide. No CREATE USER, ALTER USER, GRANT, REVOKE, AUDIT or other state-changing SQL.
Prerequisites
หัวข้อที่มีชื่อว่า “Prerequisites”Approved CDB/PDB sandbox or authorized read-only audit database account with narrowly granted access to selected DBA_/AUDIT_ views. DO NOT use production SYSDBA just to complete an exercise. Record Oracle version, actual container and observation timestamp.
Task 1 — Identify identity and container
หัวข้อที่มีชื่อว่า “Task 1 — Identify identity and container”SHOW USERSHOW CON_NAMESELECT sys_context('USERENV','SESSION_USER') session_user, sys_context('USERENV','CON_NAME') con_name FROM dual;Expected: target user/container confirmed; record only redacted evidence.
Task 2 — Account health
หัวข้อที่มีชื่อว่า “Task 2 — Account health”SELECT username,account_status,profile,default_tablespaceFROM dba_users ORDER BY username;Questions: which application accounts are expired or locked? Is the user a local PDB identity? Do not unlock or reset.
Task 3 — Privileges and roles
หัวข้อที่มีชื่อว่า “Task 3 — Privileges and roles”SELECT grantee,privilege FROM dba_sys_privsWHERE grantee='APP_USER' ORDER BY privilege;SELECT grantee,granted_role FROM dba_role_privsWHERE grantee='APP_USER' ORDER BY granted_role;SELECT owner,table_name,grantee,privilege FROM dba_tab_privsWHERE grantee='APP_USER' ORDER BY owner,table_name;Replace APP_USER with an approved example account. Discuss direct grant, role grant and definer-rights SQL behavior. Avoid blanket privileges.
Task 4 — Profiles and enforcement
หัวข้อที่มีชื่อว่า “Task 4 — Profiles and enforcement”SELECT profile,resource_name,resource_type,limit FROM dba_profilesORDER BY profile,resource_name;SELECT name,value FROM v$parameter WHERE name='resource_limit';Distinguish password limits from resource constraints; resource enforcement depends on parameter and configuration.
Task 5 — Unified audit observation
หัวข้อที่มีชื่อว่า “Task 5 — Unified audit observation”SELECT policy_name,enabled_option,entity_nameFROM audit_unified_enabled_policies;SELECT event_timestamp,dbusername,action_name,return_codeFROM unified_audit_trail ORDER BY event_timestamp DESC FETCH FIRST 10 ROWS ONLY;No rows ≠ proof of no security events. An audit account may only see authorized records; redact usernames/client details.
🔐 Unified Audit Policy Session-Lifecycle Check
หัวข้อที่มีชื่อว่า “🔐 Unified Audit Policy Session-Lifecycle Check”ใน Oracle 19c AUDIT POLICY ที่เพิ่ง Enable จะครอบคลุมการ Audit กับ Session ใหม่หลังการ Login ตาม Documented Semantics. ก่อนตีความ UNIFIED_AUDIT_TRAIL ให้ตรวจ Policy, User/Role Scope และ Login Timeline ด้วยหลักฐานที่ได้รับอนุญาต
SELECT policy_name,enabled_option,entity_name,success,failureFROM audit_unified_enabled_policies ORDER BY policy_name;Scenario: Policy Enable เวลา 09:00 แต่ Connection Pool ยังใช้ Session จาก 08:30 การไม่มี Audit Rows สำหรับ Action ใน Session เก่า ยังไม่พอจะสรุปว่า Policy Broken. ห้ามบังคับ Logout, Restart Pool หรือ Enable/Disable Policy ใน Production เพื่อให้ผ่านแบบฝึก
Oracle 19c — Policy Activation and Sessions.
Tabletop incidents
หัวข้อที่มีชื่อว่า “Tabletop incidents”- ORA-01017: inspect username/container/auth method and secret rotation.
- ORA-28000: locked account — collect cause and approval before remediation.
- ORA-00942: find object owner, direct grants and role context.
- Privileged action missing from audit: inspect policy activation/scope, audit mode and collection timing.
Exit criteria
หัวข้อที่มีชื่อว่า “Exit criteria”- Explain user versus schema, common versus local user
- Compare system and object privileges, direct grants and roles
- Identify profile/password/resource restrictions
- Understand unified audit policy versus audit trail
- No secrets exposed, no SQL mutation executed
- Mark as NOT RUN until actual approved lab testing
Cleanup: disconnect; nothing modified.
Reference: https://docs.oracle.com/en/database/oracle/oracle-database/19/dbseg/index.html
🧪 Sandbox Execution & Evidence (Optional)
หัวข้อที่มีชื่อว่า “🧪 Sandbox Execution & Evidence (Optional)”▶️ Runbook + Approved Read-only SQL Scripts · 📝 Expected vs Actual Evidence Template
Status: NOT_EXECUTED. เมื่อมี Isolated Sandbox ที่ได้รับอนุญาต ให้เลือก Script ที่ตรงหัวข้อ, บันทึก Oracle Version/RU, Container/Privileges และ Expected vs Actual ลง Private Evidence. อย่าอ้างว่า GitHub Actions PASS เท่ากับรัน Lab จริง และห้าม Commit Raw Database Output ลง Public Repository.