<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Where in repository database are labels for Action IDs stored? in Management &amp; Governance</title>
    <link>https://community.qlik.com/t5/Management-Governance/Where-in-repository-database-are-labels-for-Action-IDs-stored/m-p/2096236#M25317</link>
    <description>&lt;P&gt;The question is tied to &lt;STRONG&gt;Actions&lt;/STRONG&gt; specified in &lt;STRONG&gt;Security Rules&lt;/STRONG&gt;. Qlik Sense Repository Database (&lt;STRONG&gt;QSR&lt;/STRONG&gt;) has a table named &lt;CODE&gt;SystemRules&lt;/CODE&gt;. That table holds all of the security rules that exist in Qlik Sense server.&lt;/P&gt;
&lt;P&gt;In &lt;CODE&gt;SystemRules&lt;/CODE&gt; table, there is a column called &lt;CODE&gt;Actions&lt;/CODE&gt;. &lt;CODE&gt;Actions&lt;/CODE&gt; column holds numbers like &lt;STRONG&gt;2&lt;/STRONG&gt;, and &lt;STRONG&gt;15&lt;/STRONG&gt;, and &lt;STRONG&gt;2080&lt;/STRONG&gt;, and several others. I'm trying to find a corresponding table that maps Action IDs to Action names.&lt;/P&gt;
&lt;P&gt;Simply looking at security rules in QMC and the corresponding records in QSR, I can tell that Action ID&amp;nbsp;&lt;STRONG&gt;2&lt;/STRONG&gt; is an ID for &lt;STRONG&gt;Read&lt;/STRONG&gt; action, at least on my server. Action ID&amp;nbsp;&lt;STRONG&gt;15&lt;/STRONG&gt; is an ID for a combination of &lt;STRONG&gt;Create, Read, Update, and Delete&lt;/STRONG&gt; actions.&lt;/P&gt;
&lt;P&gt;I went through the whole repository database, but I can't find a table that matches Action IDs to Action Names.&lt;/P&gt;
&lt;P&gt;Does anyone know if a table like that exists?&lt;/P&gt;</description>
    <pubDate>Fri, 21 Jul 2023 17:59:00 GMT</pubDate>
    <dc:creator>mbespartochnyy</dc:creator>
    <dc:date>2023-07-21T17:59:00Z</dc:date>
    <item>
      <title>Where in repository database are labels for Action IDs stored?</title>
      <link>https://community.qlik.com/t5/Management-Governance/Where-in-repository-database-are-labels-for-Action-IDs-stored/m-p/2096236#M25317</link>
      <description>&lt;P&gt;The question is tied to &lt;STRONG&gt;Actions&lt;/STRONG&gt; specified in &lt;STRONG&gt;Security Rules&lt;/STRONG&gt;. Qlik Sense Repository Database (&lt;STRONG&gt;QSR&lt;/STRONG&gt;) has a table named &lt;CODE&gt;SystemRules&lt;/CODE&gt;. That table holds all of the security rules that exist in Qlik Sense server.&lt;/P&gt;
&lt;P&gt;In &lt;CODE&gt;SystemRules&lt;/CODE&gt; table, there is a column called &lt;CODE&gt;Actions&lt;/CODE&gt;. &lt;CODE&gt;Actions&lt;/CODE&gt; column holds numbers like &lt;STRONG&gt;2&lt;/STRONG&gt;, and &lt;STRONG&gt;15&lt;/STRONG&gt;, and &lt;STRONG&gt;2080&lt;/STRONG&gt;, and several others. I'm trying to find a corresponding table that maps Action IDs to Action names.&lt;/P&gt;
&lt;P&gt;Simply looking at security rules in QMC and the corresponding records in QSR, I can tell that Action ID&amp;nbsp;&lt;STRONG&gt;2&lt;/STRONG&gt; is an ID for &lt;STRONG&gt;Read&lt;/STRONG&gt; action, at least on my server. Action ID&amp;nbsp;&lt;STRONG&gt;15&lt;/STRONG&gt; is an ID for a combination of &lt;STRONG&gt;Create, Read, Update, and Delete&lt;/STRONG&gt; actions.&lt;/P&gt;
&lt;P&gt;I went through the whole repository database, but I can't find a table that matches Action IDs to Action Names.&lt;/P&gt;
&lt;P&gt;Does anyone know if a table like that exists?&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2023 17:59:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Management-Governance/Where-in-repository-database-are-labels-for-Action-IDs-stored/m-p/2096236#M25317</guid>
      <dc:creator>mbespartochnyy</dc:creator>
      <dc:date>2023-07-21T17:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: Where in repository database are labels for Action IDs stored?</title>
      <link>https://community.qlik.com/t5/Management-Governance/Where-in-repository-database-are-labels-for-Action-IDs-stored/m-p/2096266#M25318</link>
      <description>&lt;P&gt;I think I figured it out. At least to an extent. There's &lt;STRONG&gt;13&lt;/STRONG&gt; possible actions with &lt;STRONG&gt;Create&lt;/STRONG&gt;&amp;nbsp;seeming to being the first action and &lt;STRONG&gt;Approve&lt;/STRONG&gt; being the last. The IDs stored in &lt;CODE&gt;Action&lt;/CODE&gt; column seem to be a &lt;STRONG&gt;sum&lt;/STRONG&gt; of each action's IDs. Furthermore, it looks like each action ID is multiplied by 2 to get to the ID of next action.&lt;/P&gt;
&lt;P&gt;Here's a visual representation of that:&lt;/P&gt;
&lt;TABLE style="width: 100%; color: #001233; border-style: hidden;" border="1"&gt;
&lt;TBODY&gt;
&lt;TR style="background-color: #001233; color: #ffffff;"&gt;
&lt;TD width="50%" height="25px"&gt;Action ID&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;Action Name&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="25px"&gt;1&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;Create&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="background-color: #e8f1f2;"&gt;
&lt;TD width="50%" height="25px"&gt;2&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;Read&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="25px"&gt;4&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;Update&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="background-color: #e8f1f2;"&gt;
&lt;TD width="50%" height="25px"&gt;8&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;Delete&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="25px"&gt;16&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;Export&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="background-color: #e8f1f2;"&gt;
&lt;TD width="50%" height="25px"&gt;32&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;Publish&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="25px"&gt;64&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;Change owner&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="background-color: #e8f1f2;"&gt;
&lt;TD width="50%" height="25px"&gt;128&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;Change role&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="25px"&gt;256&lt;/TD&gt;
&lt;TD height="25px"&gt;Export data&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="background-color: #e8f1f2;"&gt;
&lt;TD width="50%" height="25px"&gt;512&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;Access offline&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="25px"&gt;1024&lt;/TD&gt;
&lt;TD height="25px"&gt;Distribute&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="background-color: #e8f1f2;"&gt;
&lt;TD height="25px"&gt;2048&lt;/TD&gt;
&lt;TD height="25px"&gt;Duplicate&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="25px"&gt;4096&lt;/TD&gt;
&lt;TD height="25px"&gt;Approve&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I add up &lt;STRONG&gt;Create&lt;/STRONG&gt;, &lt;STRONG&gt;Read&lt;/STRONG&gt;, &lt;STRONG&gt;Update&lt;/STRONG&gt;, and &lt;STRONG&gt;Delete&lt;/STRONG&gt; IDs, I do get &lt;STRONG&gt;15&lt;/STRONG&gt;. There are other IDs like &lt;STRONG&gt;6271&lt;/STRONG&gt; which is used for&amp;nbsp;Create, Read, Update, Delete, Export, Publish, Change owner, Duplicate, and Approve collection of actions. Adding up IDs for these nine actions, will give a sum of &lt;STRONG&gt;6271&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;The remaining thing that I'm not sure about is why when a rule permits access to &lt;STRONG&gt;all&lt;/STRONG&gt;&amp;nbsp;possible actions, the ID that is stored in &lt;CODE&gt;Actions&lt;/CODE&gt; column in &lt;CODE&gt;SystemRules&lt;/CODE&gt; table is&amp;nbsp;&lt;STRONG&gt;4294967295&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;4294967295 is a perfect totient, it's 2&lt;SUP&gt;32&lt;/SUP&gt;-1, in hex it's FFFFFFFF. I don't quite see what that has to do with&amp;nbsp; it representing &lt;STRONG&gt;all possible values&lt;/STRONG&gt; in an array? Does anyone here know the answer?&lt;/P&gt;
&lt;P&gt;Mikhail B.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2023 20:33:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Management-Governance/Where-in-repository-database-are-labels-for-Action-IDs-stored/m-p/2096266#M25318</guid>
      <dc:creator>mbespartochnyy</dc:creator>
      <dc:date>2023-07-21T20:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: Where in repository database are labels for Action IDs stored?</title>
      <link>https://community.qlik.com/t5/Management-Governance/Where-in-repository-database-are-labels-for-Action-IDs-stored/m-p/2097163#M25332</link>
      <description>&lt;P&gt;It's not obvious what you're trying to do, but the actions are bitmasked (reference&amp;nbsp;&lt;A href="https://community.qlik.com/t5/Design/Bit-operators-How-to-operate-with-multiple-values-stored-in-one/ba-p/1466705" target="_blank"&gt;https://community.qlik.com/t5/Design/Bit-operators-How-to-operate-with-multiple-values-stored-in-one/ba-p/1466705&lt;/A&gt;&amp;nbsp;for a primer on the topic).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For Security rules you can use logic like this:&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;LIB CONNECT TO 'PostgreSQL_QSR';


LOAD *,
	IF([Actions] bitand 1,'True','False') AS [create_flag],
	IF([Actions] bitand 2,'True','False') AS [read_flag],
	IF([Actions] bitand 4,'True','False') AS [update_flag],
	IF([Actions] bitand 8,'True','False') AS [delete_flag],
	IF([Actions] bitand 16,'True','False') AS [export_flag],
	IF([Actions] bitand 32,'True','False') AS [publish_flag],
	IF([Actions] bitand 64,'True','False') AS [change_owner_flag],
	IF([Actions] bitand 128,'True','False') AS [change_role_flag],
	IF([Actions] bitand 256,'True','False') AS [export_data_flag],
	IF([Actions] bitand 512,'True','False') AS [access_offline_flag],
	IF([Actions] bitand 1024,'True','False') AS [distribute_flag],
	IF([Actions] bitand 2048,'True','False') AS [duplicate_flag],
	IF([Actions] bitand 4096,'True','False') AS [approve_flag],

    ;
LOAD ID, 
	Category, 
	Type, 
	Name, 
	Rule, 
	ResourceFilter, 
	Actions, 
	Comment, 
	Disabled, 
	RuleContext, 
	SeedId, 
	Version, 
	CreatedDate, 
	ModifiedDate, 
	ModifiedByUserName, 
	Subcategory;

[SystemRules]:
SELECT "ID",
	"Category",
	"Type",
	"Name",
	"Rule",
	"ResourceFilter",
	"Actions",
	"Comment",
	"Disabled",
	"RuleContext",
	"SeedId",
	"Version",
	"CreatedDate",
	"ModifiedDate",
	"ModifiedByUserName",
	"Subcategory"
FROM "public"."SystemRules"
WHERE "Category" = 'Security';
&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 25 Jul 2023 19:15:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Management-Governance/Where-in-repository-database-are-labels-for-Action-IDs-stored/m-p/2097163#M25332</guid>
      <dc:creator>Levi_Turner</dc:creator>
      <dc:date>2023-07-25T19:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: Where in repository database are labels for Action IDs stored?</title>
      <link>https://community.qlik.com/t5/Management-Governance/Where-in-repository-database-are-labels-for-Action-IDs-stored/m-p/2097545#M25340</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/47469"&gt;@Levi_Turner&lt;/a&gt;&amp;nbsp;you read my mind! Thank you for the reference article and the script! That's exactly what I was looking for.&lt;/P&gt;
&lt;P&gt;I didn't know about bitwise operators but reading through the article you shared and checking out few YouTube videos (&lt;A title="C bitwise operators" href="https://youtu.be/BGeOwlIGRGI" target="_blank" rel="noopener"&gt;this one&lt;/A&gt; is good), it became clear.&lt;/P&gt;
&lt;P&gt;There are &lt;STRONG&gt;13&lt;/STRONG&gt; possible Actions, each represented by a bit in a binary number. Converting a value stored in &lt;CODE&gt;Actions&lt;/CODE&gt; column of &lt;CODE&gt;SystemRules&lt;/CODE&gt; table into binary will tell which action is allowed based on which bit is set to &lt;CODE&gt;1&lt;/CODE&gt;.&lt;/P&gt;
&lt;P&gt;&lt;CODE&gt;bitand&lt;/CODE&gt; function can then be used to find if a particular bit of the value in &lt;CODE&gt;Actions&lt;/CODE&gt; column is set to &lt;CODE&gt;1&lt;/CODE&gt;, effectively showing whether a particular action has been granted of not.&lt;/P&gt;
&lt;P&gt;Thanks again for the reply, script, and reference articles!&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2023 16:40:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Management-Governance/Where-in-repository-database-are-labels-for-Action-IDs-stored/m-p/2097545#M25340</guid>
      <dc:creator>mbespartochnyy</dc:creator>
      <dc:date>2023-07-26T16:40:43Z</dc:date>
    </item>
  </channel>
</rss>

