<?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 Re: How to calculate set flags in a numeric value in a search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-set-flags-in-a-numeric-value-in-a-search/m-p/172927#M49581</link>
    <description>&lt;P&gt;I did the following in &lt;CODE&gt;props.conf&lt;/CODE&gt; to handle this, but you could easily adapt it for the search language:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EVAL-bit1 = (flagField%2)
EVAL-bit2 = (floor(flagField/2)%2)
EVAL-bit3 = (floor(flagField/4)%2)
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This assigns 0 or 1 to a field &lt;CODE&gt;bit(n)&lt;/CODE&gt; based on its value in the bitmap field.&lt;/P&gt;

&lt;P&gt;So in your case, in the search bar you might say:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval IsLocked=(floor(ADS_USER_FLAG_ENUM/16)%2) | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
    <pubDate>Mon, 20 Oct 2014 15:39:48 GMT</pubDate>
    <dc:creator>aweitzman</dc:creator>
    <dc:date>2014-10-20T15:39:48Z</dc:date>
    <item>
      <title>How to calculate set flags in a numeric value in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-set-flags-in-a-numeric-value-in-a-search/m-p/172926#M49580</link>
      <description>&lt;P&gt;I have a numeric value representing flags. It is the value in userAccountControl defined as follows:&lt;/P&gt;

&lt;P&gt;typedef enum  { &lt;BR /&gt;
  ADS_UF_SCRIPT                     = 1,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// 0x1&lt;BR /&gt;
  ADS_UF_ACCOUNTDISABLE                 = 2,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// 0x2&lt;BR /&gt;
  ADS_UF_HOMEDIR_REQUIRED               = 8,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// 0x8&lt;BR /&gt;
  ADS_UF_LOCKOUT                        = 16,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// 0x10&lt;BR /&gt;
  ADS_UF_PASSWD_NOTREQD             = 32,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// 0x20&lt;BR /&gt;
  ADS_UF_PASSWD_CANT_CHANGE             = 64,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// 0x40&lt;BR /&gt;
  ADS_UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED    = 128,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// 0x80&lt;BR /&gt;
  ADS_UF_TEMP_DUPLICATE_ACCOUNT         = 256,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// 0x100&lt;BR /&gt;
  ADS_UF_NORMAL_ACCOUNT                 = 512,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// 0x200&lt;BR /&gt;
  ADS_UF_INTERDOMAIN_TRUST_ACCOUNT          = 2048,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// 0x800&lt;BR /&gt;
  ADS_UF_WORKSTATION_TRUST_ACCOUNT          = 4096,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// 0x1000&lt;BR /&gt;
  ADS_UF_SERVER_TRUST_ACCOUNT               = 8192,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// 0x2000&lt;BR /&gt;
  ADS_UF_DONT_EXPIRE_PASSWD             = 65536,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// 0x10000&lt;BR /&gt;
  ADS_UF_MNS_LOGON_ACCOUNT              = 131072,&amp;nbsp;&amp;nbsp;&amp;nbsp;// 0x20000&lt;BR /&gt;
  ADS_UF_SMARTCARD_REQUIRED             = 262144,&amp;nbsp;&amp;nbsp;&amp;nbsp;// 0x40000&lt;BR /&gt;
  ADS_UF_TRUSTED_FOR_DELEGATION         = 524288,&amp;nbsp;&amp;nbsp;&amp;nbsp;// 0x80000&lt;BR /&gt;
  ADS_UF_NOT_DELEGATED                  = 1048576,&amp;nbsp;&amp;nbsp;// 0x100000&lt;BR /&gt;
  ADS_UF_USE_DES_KEY_ONLY               = 2097152,&amp;nbsp;&amp;nbsp;// 0x200000&lt;BR /&gt;
  ADS_UF_DONT_REQUIRE_PREAUTH               = 4194304,&amp;nbsp;&amp;nbsp;// 0x400000&lt;BR /&gt;
  ADS_UF_PASSWORD_EXPIRED               = 8388608,&amp;nbsp;&amp;nbsp;// 0x800000&lt;BR /&gt;
  ADS_UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION&amp;nbsp;&amp;nbsp;= 16777216&amp;nbsp;// 0x1000000&lt;BR /&gt;
} ADS_USER_FLAG_ENUM;&lt;/P&gt;

&lt;P&gt;So i seek to know if the user is locked but i would be interested in a more generic approach. Perhaps a lookup and a custom command? search language is prefered though.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:56:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-set-flags-in-a-numeric-value-in-a-search/m-p/172926#M49580</guid>
      <dc:creator>dominiquevocat</dc:creator>
      <dc:date>2020-09-28T17:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate set flags in a numeric value in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-set-flags-in-a-numeric-value-in-a-search/m-p/172927#M49581</link>
      <description>&lt;P&gt;I did the following in &lt;CODE&gt;props.conf&lt;/CODE&gt; to handle this, but you could easily adapt it for the search language:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EVAL-bit1 = (flagField%2)
EVAL-bit2 = (floor(flagField/2)%2)
EVAL-bit3 = (floor(flagField/4)%2)
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This assigns 0 or 1 to a field &lt;CODE&gt;bit(n)&lt;/CODE&gt; based on its value in the bitmap field.&lt;/P&gt;

&lt;P&gt;So in your case, in the search bar you might say:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval IsLocked=(floor(ADS_USER_FLAG_ENUM/16)%2) | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Oct 2014 15:39:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-set-flags-in-a-numeric-value-in-a-search/m-p/172927#M49581</guid>
      <dc:creator>aweitzman</dc:creator>
      <dc:date>2014-10-20T15:39:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate set flags in a numeric value in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-set-flags-in-a-numeric-value-in-a-search/m-p/172928#M49582</link>
      <description>&lt;P&gt;Looks neat, will give it a go. Actually the v1 of SA-ldapsearch did this parsing, the new version 2 does not yet do it! Something for Adrian Hall? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Oct 2014 12:10:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-set-flags-in-a-numeric-value-in-a-search/m-p/172928#M49582</guid>
      <dc:creator>dominiquevocat</dc:creator>
      <dc:date>2014-10-21T12:10:01Z</dc:date>
    </item>
  </channel>
</rss>

