# Does logstash jdbc connection work with Windows Authentication?

**URL:** <https://discuss.elastic.co/t/does-logstash-jdbc-connection-work-with-windows-authentication/141562>\
**Category:** Logstash\
**Created:** [July 25, 2018, 12:23pm UTC](https://discuss.elastic.co/t/does-logstash-jdbc-connection-work-with-windows-authentication/141562 "2018-07-25T12:23:44Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Palash\_Tichkule](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Palash\_Tichkule](https://discuss.elastic.co/u/Palash_Tichkule)\
**Post date:** [July 25, 2018, 12:23pm UTC](https://discuss.elastic.co/t/does-logstash-jdbc-connection-work-with-windows-authentication/141562/1 "2018-07-25T12:23:45Z")

</div>

How to use logstash JDBC connection with Windows Authentication. The server does not accepts username and password even if they are passed

---

<div class="post-metadata">

**Author:** ![ganessen23](https://avatars.discourse-cdn.com/v4/letter/g/b5a626/32.png) [@ganessen23](https://discuss.elastic.co/u/ganessen23)\
**Post date:** [July 27, 2018, 6:52am UTC](https://discuss.elastic.co/t/does-logstash-jdbc-connection-work-with-windows-authentication/141562/2 "2018-07-27T06:52:01Z")

</div>

Hello,

I am having the same problem. I am using SQL server installed on a particular windows server and Logstash/Elasticsearch installed on a linux machine.  
I am unable to import data to Elasticsearch using logstash JDBC connection with Windows Authentication.

See error in screen shot below:

 ![error_jdbc](https://us1.discourse-cdn.com/elastic/original/3X/4/9/49db86679a2639f96f8d205ec7ee8e6ee323eb07.png)

And I am using the following settings in the configuration of logstash (on my local pc):

```
input { 
	jdbc{
			
			
			jdbc_driver_library => "C:\Users\g.mootheeveeren\Desktop\sqljdbc_4.2\enu\jre8\sqljdbc42.jar"	
			jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"					
			jdbc_connection_string => "jdbc:sqlserver://MAEGWDDFZ:1433;integratedsecurity=true;databasename=BI_STG_PROD"
			jdbc_user => "g.mootheeveeren"
			jdbc_password => ""			
			schedule => "* * * * *"			
			statement => "select * from TABLE_X"
	}
}

output {
  elasticsearch { 
		  hosts => ["localhost:9201"] 		  
		  index => "index1"
		  document_type => "index1"
		  document_id => "%{[id]}_%{[compare_date]}" 
				}
		stdout {}
		}

```

My question would be: Is there a way to import data from the SQL server using the **WINDOWS authentication mode?**

Thanks in advance,  
Ganessen.

---

<div class="post-metadata">

**Author:** ![Palash\_Tichkule](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Palash\_Tichkule](https://discuss.elastic.co/u/Palash_Tichkule)\
**Post date:** [July 27, 2018, 9:28am UTC](https://discuss.elastic.co/t/does-logstash-jdbc-connection-work-with-windows-authentication/141562/3 "2018-07-27T09:28:54Z")

</div>

I am searching solution for the same issue. But, It doesn't seem to work.

Python script to sync data can be other option that can be tried.

---

<div class="post-metadata">

**Author:** ![ganessen23](https://avatars.discourse-cdn.com/v4/letter/g/b5a626/32.png) [@ganessen23](https://discuss.elastic.co/u/ganessen23)\
**Post date:** [July 27, 2018, 11:30am UTC](https://discuss.elastic.co/t/does-logstash-jdbc-connection-work-with-windows-authentication/141562/4 "2018-07-27T11:30:59Z")

</div>

Hello,

I did find a solution. You have to copy the file `sqljdbc_auth.dll` found in your jdbc driver folder, to your JAVA path `C:\Program Files\Java\jre_Version\bin`.  
Dont forget to add user you are using to your SQL server in the statement: jdbc\_user =\> "xxx"

Ganessen.

---

<div class="post-metadata">

**Author:** ![Palash\_Tichkule](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Palash\_Tichkule](https://discuss.elastic.co/u/Palash_Tichkule)\
**Post date:** [July 30, 2018, 8:34am UTC](https://discuss.elastic.co/t/does-logstash-jdbc-connection-work-with-windows-authentication/141562/5 "2018-07-30T08:34:23Z")

</div>

Thanks Ganessen!!  
It worked for me as well. Instead of copying sqljdbc\_auth.dll to C:\Program Files\Java\jre\_Version\bin. I just added the dll path in Env variable.

---

<div class="post-metadata">

**Author:** ![ganessen23](https://avatars.discourse-cdn.com/v4/letter/g/b5a626/32.png) [@ganessen23](https://discuss.elastic.co/u/ganessen23)\
**Post date:** [July 30, 2018, 9:05am UTC](https://discuss.elastic.co/t/does-logstash-jdbc-connection-work-with-windows-authentication/141562/6 "2018-07-30T09:05:21Z")

</div>

Adding the dll path in the environment variable did not work for me, thats why i copied it to the mentioned path.

Your are welcomed..

---

<div class="post-metadata">

**Author:** ![Palash\_Tichkule](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Palash\_Tichkule](https://discuss.elastic.co/u/Palash_Tichkule)\
**Post date:** [July 30, 2018, 9:27am UTC](https://discuss.elastic.co/t/does-logstash-jdbc-connection-work-with-windows-authentication/141562/7 "2018-07-30T09:27:26Z")

</div>

Have you tried restarting the console? I had to restart the console for it to work.

---

<div class="post-metadata">

**Author:** ![ganessen23](https://avatars.discourse-cdn.com/v4/letter/g/b5a626/32.png) [@ganessen23](https://discuss.elastic.co/u/ganessen23)\
**Post date:** [July 30, 2018, 11:38am UTC](https://discuss.elastic.co/t/does-logstash-jdbc-connection-work-with-windows-authentication/141562/8 "2018-07-30T11:38:26Z")

</div>

Could you please send a screen shot where you added the dll path in your env. variable.

Thanks Palash.

---

<div class="post-metadata">

**Author:** ![Palash\_Tichkule](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Palash\_Tichkule](https://discuss.elastic.co/u/Palash_Tichkule)\
**Post date:** [July 31, 2018, 4:40am UTC](https://discuss.elastic.co/t/does-logstash-jdbc-connection-work-with-windows-authentication/141562/9 "2018-07-31T04:40:58Z")

</div>

![image](https://us1.discourse-cdn.com/elastic/original/3X/c/d/cd4e573f80c4e0b8fa11adcf2de8b74a921c0559.png)  
I have added `"C:\sqljdbc_4.2\enu\auth\x64"` to path

---

<div class="post-metadata">

**Author:** ![ganessen23](https://avatars.discourse-cdn.com/v4/letter/g/b5a626/32.png) [@ganessen23](https://discuss.elastic.co/u/ganessen23)\
**Post date:** [August 3, 2018, 2:11pm UTC](https://discuss.elastic.co/t/does-logstash-jdbc-connection-work-with-windows-authentication/141562/10 "2018-08-03T14:11:09Z")

</div>

Hello,

I am having issue.

I am importing data from a SQL server database to an elasticsearch instance installed on a linux machine where logstash is installed on the logstash.

See below for the config used for logstash:

```
input { 
    
	
	jdbc{			
		#jdbc_driver_library => "/home/adminemea/sqljdbc_6.0/enu/jre8/sqljdbc42.jar"	#previously used driver library
		#jdbc_driver_library => "/usr/share/java/sqljdbc42.jar" #previously used driver library
		jdbc_driver_library => "/home/adminemea/jtds-1.3.1/jtds-1.3.1.jar"
		
		
		#jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver" #previously used driver class
		jdbc_driver_class => "Java::net.sourceforge.jtds.jdbc.Driver"					
		jdbc_connection_string => "jdbc:jtds:sqlserver://IPADRESS:1433;instanceName=INSTANCENAME;databasename=DATABASENAME;integratedSecurity=true"
		
		jdbc_user => "g.mootheeveeren"		
		schedule => "* * * * *"			
		statement => "select * from TABLEX"
		
	}
}

output {

			elasticsearch { 
			hosts => ["localhost:9200"] 
			user => "elastic"
			password => "octochangeme"
			index => "synchonisation"
			document_type => "synchonisation"
			
			}
			stdout {}
	
		}

```

Error obtained in logstash log:

> [2018-08-03T13:32:00,942][ERROR][logstash.inputs.jdbc] Unable to connect to database. Tried 1 times {:error\_message=\>"Java::JavaSql::SQLException: I/O Error: GSS Failed: Invalid name provided (Mechanism level: KrbException: Cannot locate default realm)"}

I have the following questions:

1. Which JDBC driver library should i use?  
I should point out that I am using a linux machine.  
Driver used:  
1st attempt:  
[https://www.microsoft.com/en-us/download/details.aspx?id=56615](https://www.microsoft.com/en-us/download/details.aspx?id=56615)

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/2/8205f7ae425ea7a913ce2f73649050806f7551e5.png)

2nd attempt:

> **[jTDS - SQL Server and Sybase JDBC driver - Browse Files at SourceForge.net](https://sourceforge.net/projects/jtds/files/)**
>
> Open source JDBC 3.0 type 4 driver for Microsoft SQL Server (6.5 up to 2012) and Sybase ASE. jTDS is a complete implementation of the JDBC 3.0 spec…

1. Why jdbc driver should i use?  
`jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"` --\> This corresponds to a windows OS.  
or  
`jdbc_driver_class => "Java::net.sourceforge.jtds.jdbc.Driver"` --\> This corresponds to a linux OS.

2. Is the jdbc connection being correctly used?  
`jdbc_connection_string => "jdbc:jtds:sqlserver://IPADRESS:1433;instanceName=INSTANCENAME;databasename=DATABASENAME;integratedSecurity=true"`

3. I used the following command `export CLASSPATH=/home/adminemea/sqljdbc_6.0/enu/jre8/sqljdbc42.jar` to set path for Java.  
Should i re-execute the command if I'm using the soma another jar file.

4. What should i do to resolve my problem?

Kind regards,  
Ganessen.

---

<div class="post-metadata">

**Author:** ![ganessen23](https://avatars.discourse-cdn.com/v4/letter/g/b5a626/32.png) [@ganessen23](https://discuss.elastic.co/u/ganessen23)\
**Post date:** [August 6, 2018, 6:07am UTC](https://discuss.elastic.co/t/does-logstash-jdbc-connection-work-with-windows-authentication/141562/11 "2018-08-06T06:07:30Z")

</div>

Hello,

Can someone please help me?

Regards,  
Ganessen.

---

<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:** [September 3, 2018, 6:07am UTC](https://discuss.elastic.co/t/does-logstash-jdbc-connection-work-with-windows-authentication/141562/12 "2018-09-03T06:07:31Z")

</div>

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