<?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: Create saved search via javascript, for user that does not have saved search create rights in Security</title>
    <link>https://community.splunk.com/t5/Security/Create-saved-search-via-javascript-for-user-that-does-not-have/m-p/573481#M15694</link>
    <description>&lt;P&gt;Splunk JDK is taking credentials of currently logged in user so, since your regular "user" do not have sufficient permissions, they will not be able to create saved searches and can't create a saved search as some other user (admin in your case).&amp;nbsp;&lt;/P&gt;&lt;P&gt;Splunk has created different roles so that people with right knowledge get right access. For users who should create an alert, why not give them "power" user access with which they should be able to create alerts. See more details on Splunk user roles here:&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.2.2/Security/Aboutusersandroles" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.2.2/Security/Aboutusersandroles&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 03 Nov 2021 13:48:21 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2021-11-03T13:48:21Z</dc:date>
    <item>
      <title>Create saved search via javascript, for user that does not have saved search create rights</title>
      <link>https://community.splunk.com/t5/Security/Create-saved-search-via-javascript-for-user-that-does-not-have/m-p/573462#M15693</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Our app has a functionality where users can create alerts for specific events. Unfortunately the users do not have the rights to create saved searches (we are on a multi-tenant platform, so we cannot change user rights).&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code for this is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;var service = mvc.createService(); 
var mySavedSearches = service.savedSearches();
mySavedSearches.init(admin_service, {app:"APP", sharing:"app"});

// Create a saved search/report as an alert.
// service.savedSearches().create(alertOptions, function (err, alert) {

mySavedSearches.create(alertOptions, function (err, alert) {
  console.log("ALERT");
  // Error checking.
 if (err &amp;amp;&amp;amp; err.status === 409) {
  console.error("ERROR: A saved alert with the name '" + alertOptions.name + 
  "' already exists");
  error(alertOptions.name);
  return;
  } else if (err) {
  console.error("There was an error creating the alert:", err);
  return;
  }

  // Confirmation message.
  console.log("Created alert: " + alert.name);
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When logged in as an admin user, the saved searches are created. However, when logged in as a normal user, the following error appears:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;User 'user' with roles { db_connect_user, user } cannot write: /nobody/APP/savedsearches/test_saved_search { read : [ admin, user ], write : [ admin ] }, export: app, removable: no, modtime: 1559130962.504602000&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would it be possible to create these saved searches as admin, by for instance creating a service with the admin user? How could I do this? I have tried:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;var service = mvc.createService({ owner: "admin" })&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but this did not work.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Nov 2021 10:29:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Create-saved-search-via-javascript-for-user-that-does-not-have/m-p/573462#M15693</guid>
      <dc:creator>BernardEAI</dc:creator>
      <dc:date>2021-11-03T10:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: Create saved search via javascript, for user that does not have saved search create rights</title>
      <link>https://community.splunk.com/t5/Security/Create-saved-search-via-javascript-for-user-that-does-not-have/m-p/573481#M15694</link>
      <description>&lt;P&gt;Splunk JDK is taking credentials of currently logged in user so, since your regular "user" do not have sufficient permissions, they will not be able to create saved searches and can't create a saved search as some other user (admin in your case).&amp;nbsp;&lt;/P&gt;&lt;P&gt;Splunk has created different roles so that people with right knowledge get right access. For users who should create an alert, why not give them "power" user access with which they should be able to create alerts. See more details on Splunk user roles here:&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.2.2/Security/Aboutusersandroles" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.2.2/Security/Aboutusersandroles&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Nov 2021 13:48:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Create-saved-search-via-javascript-for-user-that-does-not-have/m-p/573481#M15694</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2021-11-03T13:48:21Z</dc:date>
    </item>
  </channel>
</rss>

