<?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: current user in search? in Security</title>
    <link>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54611#M1811</link>
    <description>&lt;P&gt;How would I expose python code to the search bar?&lt;/P&gt;</description>
    <pubDate>Mon, 08 Aug 2011 19:07:54 GMT</pubDate>
    <dc:creator>jgauthier</dc:creator>
    <dc:date>2011-08-08T19:07:54Z</dc:date>
    <item>
      <title>current user in search?</title>
      <link>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54607#M1807</link>
      <description>&lt;P&gt;Is is possible to pull the current user name for use in a search?&lt;BR /&gt;
For instance, a search that would do something like 'sourcetype="blah" user=$user | stats galore'&lt;/P&gt;

&lt;P&gt;My long term goal is to populate list =ers based on user, and their employees.  That data would come from AD.  I have authentication with LDAP already, so this should match up pretty easily.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2011 20:10:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54607#M1807</guid>
      <dc:creator>jgauthier</dc:creator>
      <dc:date>2011-08-05T20:10:32Z</dc:date>
    </item>
    <item>
      <title>Re: current user in search?</title>
      <link>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54608#M1808</link>
      <description>&lt;P&gt;Just to clarify, by "current user name" do you mean the user currently logged in to Splunk?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2011 23:21:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54608#M1808</guid>
      <dc:creator>acdevlin</dc:creator>
      <dc:date>2011-08-05T23:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: current user in search?</title>
      <link>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54609#M1809</link>
      <description>&lt;P&gt;I know that when I display my page, I see my user name.  I looked and python has several known variables.&lt;BR /&gt;
    $SPLUNK_HOME/share/splunk/search_mrsparkle/modules/nav/AccountBar.html&lt;/P&gt;

&lt;P&gt;so, it seems possiable to do your search with the username, at least in python.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:47:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54609#M1809</guid>
      <dc:creator>fk319</dc:creator>
      <dc:date>2020-09-28T09:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: current user in search?</title>
      <link>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54610#M1810</link>
      <description>&lt;P&gt;Yes.  The user logged into the web interface, potentially running reports.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2011 19:05:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54610#M1810</guid>
      <dc:creator>jgauthier</dc:creator>
      <dc:date>2011-08-08T19:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: current user in search?</title>
      <link>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54611#M1811</link>
      <description>&lt;P&gt;How would I expose python code to the search bar?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2011 19:07:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54611#M1811</guid>
      <dc:creator>jgauthier</dc:creator>
      <dc:date>2011-08-08T19:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: current user in search?</title>
      <link>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54612#M1812</link>
      <description>&lt;P&gt;You can, without any custom command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rest /services/authentication/current-context/context | fields + username
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;e.g. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| head 10 | join [rest /services/authentication/current-context/context | fields + username]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;will add a new column, username, to every result&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal [ rest /services/authentication/current-context/context | fields + username | rename username as user ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;will look for all the splunk logs for the current user&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2012 10:22:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54612#M1812</guid>
      <dc:creator>Paolo_Prigione</dc:creator>
      <dc:date>2012-03-14T10:22:19Z</dc:date>
    </item>
    <item>
      <title>Re: current user in search?</title>
      <link>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54613#M1813</link>
      <description>&lt;P&gt;That's a really interesting approach.  but 'rest' is not a command for me.  Is there a minimum version number, or configuration?&lt;/P&gt;

&lt;P&gt;"Search operation 'rest' is unknown. You might not have permission to run this operation."&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2012 13:06:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54613#M1813</guid>
      <dc:creator>jgauthier</dc:creator>
      <dc:date>2012-03-14T13:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: current user in search?</title>
      <link>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54614#M1814</link>
      <description>&lt;P&gt;"rest" is a proper command, but it is available since v4.3 only (just checked in the docs). I'll paste the custom python command I was using with 4.2.x in another answer.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2012 14:39:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54614#M1814</guid>
      <dc:creator>Paolo_Prigione</dc:creator>
      <dc:date>2012-03-14T14:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: current user in search?</title>
      <link>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54615#M1815</link>
      <description>&lt;P&gt;Here's a custom python command to get the current user's username: &lt;A href="http://pastebin.com/dij6QWBR"&gt;http://pastebin.com/dij6QWBR&lt;/A&gt; . Store it in a getUsername.py script in, e.g.: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;etc/apps/search/bin/
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and append this to your commands.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[getusername]
filename = getUsername.py
passauth = true
run_in_preview = true
streaming = true
retainsevents = true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The syntax is as such:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | getusername [field=\w+]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if field is not specified, a new "splunk_username" field will be created. The value of "field" will be used otherwise.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2012 14:48:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54615#M1815</guid>
      <dc:creator>Paolo_Prigione</dc:creator>
      <dc:date>2012-03-14T14:48:32Z</dc:date>
    </item>
    <item>
      <title>Re: current user in search?</title>
      <link>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54616#M1816</link>
      <description>&lt;P&gt;Wow. That totally worked. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2012 18:50:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54616#M1816</guid>
      <dc:creator>jgauthier</dc:creator>
      <dc:date>2012-03-14T18:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: current user in search?</title>
      <link>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54617#M1817</link>
      <description>&lt;P&gt;Hello Paolo,&lt;BR /&gt;
Would you please provide the getUserName.py again? It's deleted from the pastebin.net. Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2016 11:32:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54617#M1817</guid>
      <dc:creator>htkwan</dc:creator>
      <dc:date>2016-04-29T11:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: current user in search?</title>
      <link>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54618#M1818</link>
      <description>&lt;P&gt;Hello Paolo,&lt;BR /&gt;
Could you upload again getUsername.py?. It's deleted from the pastebin.net&lt;BR /&gt;
thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2017 18:51:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54618#M1818</guid>
      <dc:creator>pablord</dc:creator>
      <dc:date>2017-02-06T18:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: current user in search?</title>
      <link>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54619#M1819</link>
      <description>&lt;P&gt;I think this is new in 6.5, but I've been able to set variables with an env call in xml&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;row&amp;gt;
&amp;lt;panel&amp;gt;
 &amp;lt;html&amp;gt;
&amp;lt;h1&amp;gt;Welcome  $env:user_realname$ &amp;lt;/h1&amp;gt;
You are logged in as $env:user$
&amp;lt;/html&amp;gt;
&amp;lt;/panel&amp;gt;
&amp;lt;/row&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Feb 2017 21:18:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/current-user-in-search/m-p/54619#M1819</guid>
      <dc:creator>AzJimbo</dc:creator>
      <dc:date>2017-02-06T21:18:12Z</dc:date>
    </item>
  </channel>
</rss>

