in

This Blog

Syndication

Advertising

mystyleit

Tomcat Authentication to Active Directory

Tomcat Authentication to Active Directory

Love IIS and its easy Authentication Model (Anonymous, Basic, Integrated)? Me too! The following post will, to the best of my ability, explain how to make Tomcat to Basic and Integrated Authentication to Active Directory (AD). It actually isn't to bad but the information is all over the place.

In order to be successful at this you will need to have a good working knowledge of Tomcat. If you don't I suggest reading this:
http://mystyleit.com/blogs/mystyleit/archive/2008/12/05/adventures-with-tomcat-5-5.aspx

Tomcat LDAP Authentication to AD (aka Basic)

If you have read the official Tomcat documentation, hopefully you know that we need to create a JNDI Realm. In this example we are going to create a Global Realm, the means it is going in the Service area of the server.xml.

Here is the link to the official documentation:
http://tomcat.apache.org/tomcat-5.5-doc/realm-howto.html#JNDIRealm

If you have read the documentation you will see that JNDI Realms support to modes, Bind mode and Comparison mode. Based on everything I have read, Bind mode does NOT work with AD. Only Comparison mode modes does.

Creating the authentication is a two step process. The steps are:

  1. We must create a global JDNI Realm
  2. Create a security constraint in the web.xml (equivalent checking off the Basic Authentication check box in IIS)

 

So lets have a look at a Comparison mode JNDI Realm. This would go in the server.xml:

So lets have a look security constraint. This goes in your applications web.xml:

Below is a link to a great MSDN web cast about setting up the same thing:
http://blogs.msdn.com/alextch/archive/2007/06/25/configuring-tomcat-to-authenticate-against-active-directory.aspx

Tomcat NTLM Authentication to AD (aka Integrated)

Next up is setting up Tomcat to use NTLM authentication (aka Integrated). This one is more complicated.

NTLM

NTLM is complicated stuff. In short there are two versions of NTLM, NTLMv1 and NTLMv2. NTLMv2 is the good stuff. NTLMv1 is the bad stuff. If you would like to know more I recommend reading the following:
http://en.wikipedia.org/wiki/NTLM
http://technet.microsoft.com/en-us/magazine/2006.08.securitywatch.aspx

JCIFS

JCIFS is a open source client library that can do all sorts of things, including to NTLM Authentication for a web app. See the following:
http://jcifs.samba.org/
http://jcifs.samba.org/src/docs/ntlmhttpauth.html

Deploying JCIFS

There are many deployment scenarios for JCIFS. The deployment I'm covering getting JCIFS to Authenticate against a Network Share. In this approach you create a secure network share, only the users who have access to the network share can access the web site.

The installation has several steps:

  1. Create a secured share and secure using NTFS permissions
  2. Download the jcifs.jar and copy to the lib folder of your web app
  3. Create the JCIFS filter in you web app's web.xml file

This guide is not going to cover how to create a network share. So look elsewhere.

Let's have a look at the JCIFS filter we need to create in the web.xml:

For more information see:
http://jcifs.samba.org/src/docs/ntlmhttpauth.html#install

The above configuration works on my Server 2008 native domain with no change to the Domain Security policy.

Conclusion

When I went to set all this up myself the first time I had a really hard time finding examples of configurations. Hopefully these examples are helpful to you.

Comments

 

Business Directory said:

I was just thinking about Authentication to Active Directory and you've really helped out. Thanks!

October 12, 2009 7:30 AM
 

SEO said:

good post

October 12, 2009 7:30 AM
 

java developer said:

Really helpful post. thank and keep up the good work

February 5, 2010 4:35 AM
 

dB. said:

JCIFs doesn't do NTLMv2 and requires far more configuration than you would like. If you're running Tomcat on Windows, there's now a new alternative: http://waffle.codeplex.com.

May 26, 2010 8:44 AM
 

dB. said:

JCIFs doesn't do NTLMv2 and requires far more configuration than you would like. If you're running Tomcat on Windows, there's now a new alternative: http://waffle.codeplex.com.

May 26, 2010 8:44 AM
 

Weight Loss Resources said:

These lists of websites are quite new for me – thanks!

July 1, 2010 10:10 AM
 

Janak Rana said:

these is absolutely wow.... I was just surprised after reading this post and example..

Thank you,,,good work.. and keep posting this type of work..

Thank you

October 20, 2010 12:31 AM
 

johnrockfellerZ said:

ADManager Plus: Active Directory Management, Reporting & Helpdesk Delegation Solution

Apart from Bulk Management for all AD objects, ADManager Plus also offers 150+reports (for IT

compliance) & helpdesk delegation! Specialty: Shortcuts for everyday AD & office management actions!

Attraction: Affordable pricing and perfect scalability!

www.manageengine.com/.../ad-manager

ADSelfServicePlus Plus:  Enterprise-Wide Password/Directory Self-Service Solution affordable even by

SMBs!

ADSelfService Plus is “4 services sold at the price of 1”! This end-user product offers password self-

service, Active Directory Self-Service Update, People Search, and Password Expiry Notifier (a very useful

tool for VPN users).

www.manageengine.com/.../self-service-password

ADAudit Plus: A tool for an in-depth auditing of Active Directory, Member & File Servers.

With this tool, you can monitor user activity such as logon, file access, etc. A configurable alert system

ADAudit Plus is a valuable security tool that will help you be compliant with all the IT regulatory acts.

warns you of potential threats.

www.manageengine.com/.../active-directory-audit

Exchange Reporter Plus: A reporting and analysis solution for MS Exchange

The tool offers Exchanger server traffic analysis, mailbox size, public folder size, & other important

reports. It is also an important security tool as it points out inactive mailboxes and offers Mailbox &

Public folder content reports!

www.manageengine.com/.../exchange-reports

February 2, 2011 7:57 AM
 

Acai Berry Diet said:

I discovered so numerous interesting stuff in your weblog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all of the enjoyment here! maintain up the great work.<a href=http://www.channel6healthreporter.com>Acai Berry Diet</a>

August 16, 2011 5:24 AM
 

how to become a pilot said:

about this topic, I have been lately in your blog once or twice now. I just wanted to say hi and show my thanks for the information provided.

September 15, 2011 4:42 AM
 

reverse address lookup said:

I will bookmark this site for future viewing.Thanks for sharing.And it is So beautiful and helpful article. I think this post composed of with some learning and acquiring lot of things.

February 9, 2012 4:14 AM
 

Futures Trading said:

I was just surprised after reading this post and example..

Thank you,,,good work.. and keep posting this type of work..

Thank you

May 9, 2012 3:36 AM

Leave a Comment

(required)  
(optional)
(required)  
Add

About mike.clarke

Mike is currently a Systems Specialist for a major Canadian software developer and the founder of mystyleit.com.