This is a test job I wrote a few weeks ago to list out my custom security policies, roles and queries associated with it into a table. Hope someone finds it useful.
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
static void DN_LoadSecPolMeta(Args _args) | |
{ | |
#AOT | |
Treenode secPolicyNode; | |
Treenode secPolicy; | |
NoYesId noyesid; | |
str secPolicyName, secRole, secQuery, strPrimaryTable; | |
int i; | |
int nodeCount; | |
DN_SecPol secpoltst; | |
secPolicyNode = treenode::findNode(#SecPoliciesPath); | |
// Count of all the secPolicys. | |
nodeCount = secPolicyNode.AOTchildNodeCount(); | |
secPolicy = secPolicyNode.AOTfirstChild(); | |
for (i=1; i<=nodeCount; ++i) | |
{ | |
secPolicyName = secPolicy.AOTgetProperty("Name"); | |
secRole = secPolicy.AOTgetProperty("RoleName"); | |
secQuery = secPolicy.AOTgetProperty("Query"); | |
if(secPolicyName like 'DN*' && secPolicy.AOTgetProperty("PolicyGroup") == 'Record Security') //Spit out only custom security policies having RLS Security | |
{ | |
secpoltst.RoleName = secRole; | |
secpoltst.PolicyName = secPolicyName; | |
secpoltst.QueryName = secQuery; | |
secpoltst.PrimaryTable = secPolicy.AOTgetProperty("PrimaryTable"); | |
secpoltst.Enabled = NoYes::Yes; | |
secpoltst.doInsert(); | |
} | |
secPolicy = secPolicy.AOTnextSibling(); | |
} | |
} |