<?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: Get current username from SplunkJS in Security</title>
    <link>https://community.splunk.com/t5/Security/Get-current-username-from-SplunkJS/m-p/116991#M3635</link>
    <description>&lt;P&gt;it works perfectly for me, thank you! Flynt.&lt;/P&gt;</description>
    <pubDate>Thu, 01 Oct 2015 07:00:20 GMT</pubDate>
    <dc:creator>clement</dc:creator>
    <dc:date>2015-10-01T07:00:20Z</dc:date>
    <item>
      <title>Get current username from SplunkJS</title>
      <link>https://community.splunk.com/t5/Security/Get-current-username-from-SplunkJS/m-p/116987#M3631</link>
      <description>&lt;P&gt;In a HTML dashboard, how can I determine the username of the current user?&lt;/P&gt;

&lt;P&gt;I tried this, but it seems like there should be a simpler synchronous way to get that information:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require(["splunkjs/mvc"],
  function(mvc) {
        var service = mvc.createService({ owner: "nobody" });
        var username = "undefined";
        service.currentUser(function(err, user) {
             console.log("User name inside: ", user.name);
             username = user.properties().name;
        });
        console.log("User name after : ", username);
  });
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Mar 2015 10:56:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Get-current-username-from-SplunkJS/m-p/116987#M3631</guid>
      <dc:creator>lassel</dc:creator>
      <dc:date>2015-03-27T10:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: Get current username from SplunkJS</title>
      <link>https://community.splunk.com/t5/Security/Get-current-username-from-SplunkJS/m-p/116988#M3632</link>
      <description>&lt;P&gt;You can do the following -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  require([ 'underscore', 'jquery', 'splunkjs/mvc', ],
      function(_, $, mvc ) {        
         var tokens = mvc.Components.getInstance("default");       
         var current=Splunk.util.getConfigValue("USERNAME");        
         tokens.set("currentuser", current);
      });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Notice I set the token in the dashboard to current. You can log it here or do with it what you wish.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2015 05:06:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Get-current-username-from-SplunkJS/m-p/116988#M3632</guid>
      <dc:creator>Flynt</dc:creator>
      <dc:date>2015-04-16T05:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: Get current username from SplunkJS</title>
      <link>https://community.splunk.com/t5/Security/Get-current-username-from-SplunkJS/m-p/116989#M3633</link>
      <description>&lt;P&gt;I have converted my dashboard to HTML and I have removed the Launcher navigation bar on the top of my dashboard but would like to add hyperlink to allow user to change their password, could you advise how to utilize your codes to replace "UserID" with login username in html tag follows?&lt;/P&gt;

&lt;P&gt;&amp;lt; a href="/manager/apps/authentication/changepassword/"UserID"?action=edit"&amp;gt;Change Password&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2015 15:59:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Get-current-username-from-SplunkJS/m-p/116989#M3633</guid>
      <dc:creator>clement</dc:creator>
      <dc:date>2015-09-30T15:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: Get current username from SplunkJS</title>
      <link>https://community.splunk.com/t5/Security/Get-current-username-from-SplunkJS/m-p/116990#M3634</link>
      <description>&lt;P&gt;Put your a where you want it to be, add an ID and don't add href. In my example I call it changepassword.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;a id="changepassword"&amp;gt;Change Password&amp;lt;/a&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then at the bottom of your HTML (Right after DASHBOARD READY) add this -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    var current=Splunk.util.getConfigValue("USERNAME");     
    var sethref='{{SPLUNKWEB_URL_PREFIX}}/manager/YOURAPPNAME/authentication/changepassword/'+current+'?action=edit' 
   $("#changepassword").attr('href',sethref);
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Make sure you change the YOURAPPNAME value in the sethref variable to be the app that the view is in.&lt;/P&gt;

&lt;P&gt;This should create a link to the change password screen.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2015 17:13:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Get-current-username-from-SplunkJS/m-p/116990#M3634</guid>
      <dc:creator>Flynt</dc:creator>
      <dc:date>2015-09-30T17:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: Get current username from SplunkJS</title>
      <link>https://community.splunk.com/t5/Security/Get-current-username-from-SplunkJS/m-p/116991#M3635</link>
      <description>&lt;P&gt;it works perfectly for me, thank you! Flynt.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 07:00:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Get-current-username-from-SplunkJS/m-p/116991#M3635</guid>
      <dc:creator>clement</dc:creator>
      <dc:date>2015-10-01T07:00:20Z</dc:date>
    </item>
  </channel>
</rss>

