All Apps and Add-ons

Splunk Java SDK How to get Email ID of current User.

disha
Contributor

Hi,
I am not very comfortable in java. So Asking this help. This could be very easy and straight for regular java users.
Scenario:
I am connecting to Splunk and Running oneshot search and I need to send email to User as notification.
I figured out like User.getEmail() will give me email of current user. But I cannot fit this in my Code.Please help where I am doing wrong.

import java.io.*;
import java.util.HashMap;

import com.splunk.*; // The entry point to the client library

public class SplunkConnect {

public static void main(String[] args) {

    // Create a map of arguments and add login parameters
    Args loginArgs = new Args();
    loginArgs.add("username", "admin");
    loginArgs.add("password", "password");
    loginArgs.add("host", "localhost");
    loginArgs.add("port", 8089);

     Create a Service instance and log in with the argument map
    Service service = Service.connect(loginArgs);
    String user= service.getUsername();
    String email=service.User.getEmail();
   System.out.println("The current user is " + user);
   System.out.println("The current user email is " + email);

Please suggest the correct way of calling getUser().
Thanks in Advance.
-Disha

Tags (1)
0 Karma

psanford_splunk
Splunk Employee
Splunk Employee

Hi - this page might be helpful for you:

http://dev.splunk.com/view/SP-CAAAEJ7

It talks about how to get the user object.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...