Skip to main content

Posts

Showing posts with the label ldap

Simple LDAP Authentication

This is a simple example through which we will connect to the LDAP Server and authenticate user. I have used ApacheDS Server as a LDAP Server. Install ApacheDS server and run it. Following is a servlet used. make login.html and use as it Login.java package ajaxdemo.action; import java.io.IOException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.naming.*; import javax.naming.directory.*; import java.util.Hashtable; public class Login extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet { public Login() { super(); } protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final String SUCCESS = "Success.html"; final String FAILURE = "Failure.html"; String strUrl = "login.html"; String username = request