# Access Elasticsearch/Kibana using Active Directory

**URL:** <https://discuss.elastic.co/t/access-elasticsearch-kibana-using-active-directory/77921>\
**Category:** Kibana\
**Created:** [March 9, 2017, 1:39am UTC](https://discuss.elastic.co/t/access-elasticsearch-kibana-using-active-directory/77921 "2017-03-09T01:39:38Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![arianayay](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@arianayay](https://discuss.elastic.co/u/arianayay)\
**Post date:** [March 9, 2017, 1:39am UTC](https://discuss.elastic.co/t/access-elasticsearch-kibana-using-active-directory/77921/1 "2017-03-09T01:39:38Z")

</div>

Hi All,

May I know why I can't connect to Elasticsearch using this setup.

```auto
xpack:
  security:
    authc:
      realms:
        active_directory:
          type: active_directory
          order: 0 
          domain_name: domainexample.com
          unmapped_groups_as_roles: true

```

Error being thrown.

```auto
  "error" : {
    "root_cause" : [
      {
        "type" : "security_exception",
        "reason" : "error attempting to authenticate request",
        "header" : {
          "WWW-Authenticate" : "Basic realm=\"security\" charset=\"UTF-8\""
        }
      }
    ],
    "type" : "security_exception",
    "reason" : "error attempting to authenticate request",
    "caused_by" : {
      "type" : "l_d_a_p_exception",
      "reason" : "An error occurred while attempting to connect to server domainexample.com:389: java.io.IOException: LDAPException(resultCode=91 (connect error), errorMessage='An error occurred while attempting to establish a connection to server domainexample.com/127.0.0.1:389: ConnectException(message='Connection refused: connect', trace='waitForConnect(null:native) / socketConnect(null:unknown) / doConnect(null:unknown) / connectToAddress(null:unknown) / connect(null:unknown) / connect(null:unknown) / connect(null:unknown) / connect(null:unknown) / run(ConnectThread.java:146)', revision=24201)')",
      "caused_by" : {
        "type" : "i_o_exception",
        "reason" : "LDAPException(resultCode=91 (connect error), errorMessage='An error occurred while attempting to establish a connection to server domainexample.com/127.0.0.1:389: ConnectException(message='Connection refused: connect', trace='waitForConnect(null:native) / socketConnect(null:unknown) / doConnect(null:unknown) / connectToAddress(null:unknown) / connect(null:unknown) / connect(null:unknown) / connect(null:unknown) / connect(null:unknown) / run(ConnectThread.java:146)', revision=24201)')",
        "caused_by" : {
          "type" : "l_d_a_p_exception",
          "reason" : "An error occurred while attempting to establish a connection to server domainexample.com/127.0.0.1:389: ConnectException(message='Connection refused: connect', trace='waitForConnect(null:native) / socketConnect(null:unknown) / doConnect(null:unknown) / connectToAddress(null:unknown) / connect(null:unknown) / connect(null:unknown) / connect(null:unknown) / connect(null:unknown) / run(ConnectThread.java:146)', revision=24201)",
          "caused_by" : {
            "type" : "connect_exception",
            "reason" : "Connection refused: connect"
          }
        }
      }
    },
    "header" : {
      "WWW-Authenticate" : "Basic realm=\"security\" charset=\"UTF-8\""
    }
  },
  "status" : 401
}

```

Thanks!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 9, 2017, 2:01am UTC](https://discuss.elastic.co/t/access-elasticsearch-kibana-using-active-directory/77921/2 "2017-03-09T02:01:47Z")

</div>

Please don't post pictures like this but text. It's hardly readable.

Please format your code using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will make your post more readable.

Or use markdown style like:

````
```
CODE
```
````

---

<div class="post-metadata">

**Author:** ![arianayay](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@arianayay](https://discuss.elastic.co/u/arianayay)\
**Post date:** [March 9, 2017, 2:21am UTC](https://discuss.elastic.co/t/access-elasticsearch-kibana-using-active-directory/77921/4 "2017-03-09T02:21:11Z")

</div>

Hi Dadoonet,

I have modified it. Please provide your inputs. Thanks!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 9, 2017, 2:33am UTC](https://discuss.elastic.co/t/access-elasticsearch-kibana-using-active-directory/77921/5 "2017-03-09T02:33:29Z")

</div>

I moved your question to #x-pack

Apparently it can't connect to the LDAP server you declared: [domainexample.com/127.0.0.1:389](http://domainexample.com/127.0.0.1:389)

---

<div class="post-metadata">

**Author:** ![arianayay](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@arianayay](https://discuss.elastic.co/u/arianayay)\
**Post date:** [March 9, 2017, 2:39am UTC](https://discuss.elastic.co/t/access-elasticsearch-kibana-using-active-directory/77921/6 "2017-03-09T02:39:04Z")

</div>

Hi All,

How can we access using LDAP? Is it the same with http? Thanks!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 9, 2017, 2:53am UTC](https://discuss.elastic.co/t/access-elasticsearch-kibana-using-active-directory/77921/7 "2017-03-09T02:53:23Z")

</div>

I meant active directory. But I know a little about security plugin so I prefer to let another one to answer.

I just meant to move your question to the right place so experts can help.

---

<div class="post-metadata">

**Author:** ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)\
**Post date:** [March 9, 2017, 3:02am UTC](https://discuss.elastic.co/t/access-elasticsearch-kibana-using-active-directory/77921/8 "2017-03-09T03:02:04Z")

</div>

Is this configuration and error message _exactly_ as they were in your testing?

If so, it looks like you are trying to connect to an AD server at `domainexample.com`, and you have mapped that domain name to your local machine (from the error message `domainexample.com/127.0.0.1`), but you aren't actually running ActiveDirectory on the localhost.

Is that what you were trying to do?

---

<div class="post-metadata">

**Author:** ![arianayay](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@arianayay](https://discuss.elastic.co/u/arianayay)\
**Post date:** [March 9, 2017, 3:38am UTC](https://discuss.elastic.co/t/access-elasticsearch-kibana-using-active-directory/77921/9 "2017-03-09T03:38:58Z")

</div>

Hi Tim,

This is not the exact configuration but close to. Also, may i know if domain\_name in the elasticsearch.yml should be the domain(DNS) of the server?

---

<div class="post-metadata">

**Author:** ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)\
**Post date:** [March 9, 2017, 3:39am UTC](https://discuss.elastic.co/t/access-elasticsearch-kibana-using-active-directory/77921/10 "2017-03-09T03:39:46Z")

</div>

> [@arianayay](#):
>
> if domain\_name in the elasticsearch.yml should be the domain(DNS) of the server?

In general, yes.

---

<div class="post-metadata">

**Author:** ![arianayay](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@arianayay](https://discuss.elastic.co/u/arianayay)\
**Post date:** [March 9, 2017, 3:51am UTC](https://discuss.elastic.co/t/access-elasticsearch-kibana-using-active-directory/77921/11 "2017-03-09T03:51:26Z")

</div>

Hi Tim,

So what I've supplied in the elasticsearch.yml is correct. But as what you've mentioned above, I was trying to connect to an AD server but I haven't mapped it to my local machine but to the IP of the server. Also, I am getting the error since I want to access using my AD account but I am not able to.

---

<div class="post-metadata">

**Author:** ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)\
**Post date:** [March 9, 2017, 3:55am UTC](https://discuss.elastic.co/t/access-elasticsearch-kibana-using-active-directory/77921/12 "2017-03-09T03:55:48Z")

</div>

I can only work from the information that you have provided.

The error message you posted very clearly has the server as `127.0.0.1` which is the local machine that elasticsearch is running on.

If that is the error message you are seeing, then it indicates that your DNS resolver thinks "[domainexample.com](http://domainexample.com)" is on the local machine. And that's not a elasticsearch issue.

If that's not the real error message, then you're going to have to work out whether the IP address that is in your message is in fact the IP of your Active Directory server. Because as far as Elasticsearch can tell, there is nothing listening on port 389 of that server. It could be that you have the wrong domain name. It could be that you have a DNS issue. It could be that you have a firewall or other network device preventing access. All of those are issues that you will have to check for yourself.

---

<div class="post-metadata">

**Author:** ![arianayay](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@arianayay](https://discuss.elastic.co/u/arianayay)\
**Post date:** [March 9, 2017, 4:03am UTC](https://discuss.elastic.co/t/access-elasticsearch-kibana-using-active-directory/77921/13 "2017-03-09T04:03:26Z")

</div>

Hi Tim,

IP provided above is just an example for the discussion but what I've supplied is the correct IP for the AD Server. If that is the case, we need to check the firewall or ports used since I have supplied the correct domain\_name for the server. Thanks for the help and FYI. we are new to this technology and still exploring its functionalities. Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 6, 2017, 4:03am UTC](https://discuss.elastic.co/t/access-elasticsearch-kibana-using-active-directory/77921/14 "2017-04-06T04:03:32Z")

</div>

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