jdbc - How to use Windows Authentication to SQL Server from a Jasper Server running on Linux -


I have running JSP Server 4.5.0 on 64-bit Linux.

Multiple SQL Server plugins available in one of the sources of data is a SQL Server with a local SQL authentication parameter.

How do I connect to the database using an Active Directory account instead of a local SQL account?

assumptions: REMOTE_IP IP address SQL Server is bound to port 1433 TCP Listening to / IP traffic and the name of the database is Jasper .

Instead of using the plain-wet sqljdbc.jar driver to connect to SQL Server, we will use a product to connect to SQL Server. The reason for this is that JDBC allows SQL Server to connect to SQL Server using Windows authentication mode.

Step:

1) Install Jasper Server 4.5.x

2) Get jTDS 1.2.5 (or whatever should do the latest work) .

You may have noticed that there are some DLLs in the JTDDS package, Dont Vorry! The driver still works in Linux. You can not do single sign-on in Linux such as Windows

Remove jtds -. * Jar jasperserver / apache-tomcat / lib to $

3) Edit $ jasperserver / apache-tomcat / conf / Catalina / localhost / jasperserver.xml and < Add the following element to the code> & lt; / Context & gt;

  & lt; Resource name = "JDBC / sqlserver" authentication = "container" type = "javax.sql.DataSource" driverClassName = "net.sourceforge.jtds.jdbc.Driver" url = "JDBC: jtds: sqlserver: // REMOTE_HOST: 1433; DatabaseName = Jasper; useCursors = false; domain = com; username = administrator password = XXXXXXX; user = admin "user =" admin "password =" XXXXXXX "maxActive =" 20 "maxIdle =" 20 "maxWait =" 60000 " RemoveAbandoned = "true" logAbandoned = "true" removeAbandonedTimeout = "300" validation = "selection1" />   

4) Edit $ jasperserver / apache-tomcat / webapps / jasperserver / WEB-INF / web.xml and add a new & lt; Resource for new data source Ref: :

  & lt; Resource-Ref & gt; & Lt; Details & gt; Connection Details & lt; / Description & gt; & Lt; Race-referee-name & gt; JDBC / sqlserver & lt; / Race-referee-name & gt; & Lt; Race Type & gt; Javax.sql.DataSource & lt; / Race Type & gt; & Lt; Race writing & gt; Container & lt; / Writing the race & gt; & Lt; / Resources Ref & gt; 5) Create a new database name "jasper" and read the * permissions for the Active Directory account that you want to use.  

6) Run this script for testing purposes:

  test test (test entry (50) null) to create test values ​​('1') insert test Enter the values ​​( "2") insert test values ​​( '3')   

7) Create a new JSP file $ jasperserver / apache-tomcat / webapps / jasperserver / test .jsp

  & lt;% @ taglib uri = "http://java.sun.com/jsp/jstl/sql" prefix = "sql"%> & Lt;% @ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c"%> & Lt; Sql: query var = "rs" data source = "jdbc / sqlserver" & gt; Choose a test from the exam & lt; / Sql: Query & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; DB Test & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; H2 & gt; Results & lt; / H2 & gt; & Lt; C: forEach var = "i" item = "$ {rs.rows}" & gt; Text message: & lt; C: out value = "$ {i.test}" /> gt; & Lt; Br> & Lt; / C: foreach & gt; & Lt; / Body & gt; & Lt; / Html & gt; 8) Start the Tomcat of jasperserver log in, and test  http: // localhost: 8080 / jasperserver / test.jsp   

You should see 1, 2 and 3 rows from the exam table.

If this does not work ... review the previous steps and see what happened wrong.

9) Just go and create a Jasper server JNDI datasource: Data Source - & gt; New data source - & gt; Type: JNDI data source. - & gt; JNDI lookup is: / jdbc / sqlserver

Create your own table and test your report.

Comments