Client Example, Elasticsearch with Active Directory Security Enabled

(Charles Bunders) #1

I am querying Elasticsearch via a client written in C# that uses Elasticsearch.NET and Nest. It works fine without security on. Once Active Directory is enabled I can query it via cURL easy enough adding user:pass as needed.

Does anyone have an example of how you need to change the C# code to get the users authentication token and then pass this in to Elasticsearch to authenticate/query against Active Directory?


(Russ Cam) #2

For Active Directory authentication, are you simply passing Basic Authentication details? From your description with how you can interact with curl, it sounds like it.

Basic Authentication details can be passed with NEST using

var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));

var connectionSettings = new ConnectionSettings(pool)
    .BasicAuthentication("username", "password");    

var client = new ElasticClient(connectionSettings);

(Charles Bunders) #3

Thanks for the response Russ. Yes the basic authentication works fine. Was wondering if there was a way to get a token from the local C# process that could be passed on to the Elasticsearch cluster, thus making it so the user didn't need to enter their password at startup.

Perhaps using OAuth like this:

(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.