How to log on to and off of Splunk Enterprise using Splunk SDK for C# v2.x

Use the LogOnAsync method of the Service class to log on to Splunk Enterprise. For example:

await service.LogOnAsync(username, password);

This code snippet assumes that you've retrieved a valid username and password from the user, and assigned each to the username and password variables.

Similarly, use the LogOffAsync method of the Service class to log off of Splunk Enterprise:

await service.LogOffAsync();

For a complete example that you can run locally, see the authenticate example in the examples directory.

Reference