Last active
June 15, 2019 05:51
-
-
Save phpdave/48908c91786f10576d23b68acd7ffe22 to your computer and use it in GitHub Desktop.
IBM i DB2 security - Scott's examples on create mask - https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_72/db2/rbafzcrtmask.htm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- QIBM_DB_ZDA (restrict ODBC and JDBC Toolbox from the server side, including Run SQL Scripts, System i Navigator and DB2 specific portions of Systems Director Navigator for i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE MASK SSN_MASK ON EMPLOYEE | |
FOR COLUMN SSN RETURN | |
CASE | |
WHEN (VERIFY_GROUP_FOR_USER(SESSION_USER,'PAYROLL') = 1) | |
THEN SSN | |
WHEN (VERIFY_GROUP_FOR_USER(SESSION_USER,'MGR') = 1) | |
THEN 'XXX-XX-' || SUBSTR(SSN,8,4) | |
ELSE NULL | |
END | |
ENABLE; | |
COMMIT; | |
ALTER TABLE EMPLOYEE | |
ACTIVATE COLUMN ACCESS CONTROL; | |
COMMIT; | |
SELECT SSN FROM EMPLOYEE | |
WHERE EMPNO = 123456; | |
SET SESSION AUTHORIZATION = testmgr; | |
select user,ssn from toystore5.employee; | |
SET SESSION AUTHORIZATION = joeemployee; | |
select user,ssn from toystore5.employee; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE PERMISSION SALARY_ROW_ACCESS ON EMPLOYEE | |
FOR ROWS WHERE VERIFY_GROUP_FOR_USER(SESSION_USER,'MGR','ACCOUNTING') = 1 | |
AND | |
ACCOUNTING_UDF(SALARY) < 120000 | |
ENFORCED FOR ALL ACCESS | |
ENABLE; | |
COMMIT; | |
ALTER TABLE EMPLOYEE | |
ACTIVATE ROW ACCESS CONTROL; | |
COMMIT; | |
SELECT SALARY FROM EMPLOYEE | |
WHERE EMPNO = 123456; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/IBM+i+Technology+Updates/page/DISPLAY_JOURNAL+%28easier+searches+of+Audit+Journal%29 | |
SELECT * FROM TABLE ( DISPLAY_JOURNAL( 'TESTLIB', 'QSQJRN')) AS JT; | |
SELECT journal_code, journal_entry_type, object, object_type, X.* | |
FROM TABLE ( | |
QSYS2.Display_Journal( | |
'PRODDATA', 'QSQJRN', -- Journal library and name | |
OBJECT_LIBRARY=>'PRODDATA', OBJECT_NAME=>'SALES', | |
OBJECT_OBJTYPE=>'*FILE', OBJECT_MEMBER=>'SALES' | |
) ) AS X | |
WHERE journal_entry_type in ('DL', 'PT', 'PX', 'UP') AND "CURRENT_USER" = 'SUPERUSER' | |
ORDER BY entry_timestamp DESC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CALL SYSPROC.SET_COLUMN_ATTRIBUTE('TOYSTORE', 'EMPLOYEE', 'SSN', 'SECURE YES'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment