An example of synchronizing LDAP and databases

Source: Internet
Author: User
Tags ldap
Import Java.io.File;
Import Java.io.FileInputStream;
Import java.io.IOException;
Import java.sql.CallableStatement;
Import java.sql.Connection;
Import java.util.ArrayList;
Import Java.util.Date;
Import java.util.Hashtable;
Import java.util.List;
Import java.util.Properties;
Import Java.util.Timer;
Import Java.util.TimerTask;

Import Javax.naming.Context;
Import javax.naming.NamingEnumeration;
Import Javax.naming.directory.Attribute;
Import Javax.naming.directory.SearchControls;
Import Javax.naming.directory.SearchResult;
Import Javax.naming.ldap.Control;
Import Javax.naming.ldap.InitialLdapContext;
Import Javax.naming.ldap.LdapContext;
Import javax.servlet.ServletException;

Import Org.apache.log4j.Logger;

Import Com.sun.jndi.ldap.ctl.PagedResultsControl;
Import Com.sun.jndi.ldap.ctl.PagedResultsResponseControl;

/** */ /**
* Servlet implementation class for Servlet:syncldapservlet
*
* @web. servlet name= "Syncldapservlet" display-name= "Syncldapservlet"
*
* @web. Servlet-mapping url-pattern= "/syncldapservlet"
*
*/
public class Syncldapservlet extends Javax.servlet.http.HttpServlet implements
Javax.servlet.Servlet ... {
/**//*
* (Non-java-doc)
*
* @see Javax.servlet.http.httpservlet#httpservlet ()
*/
private static Logger log = Logger.getlogger (Syncldapservlet.class);

Private Connection con;

private static Hashtable env = NULL;

List objlist;

Private String Remove_new_data = "";//stored procedure name for removing DATA

Private String Insert_new_data = "";//stored procedure name for INSERT NEW DATA

Private String Ldap_property_file = "";//ldap property FILE, which contains LDAP connection info


public void Init () throws servletexception ... {
Super.init ();

This.con = null;
This.emelist = new ArrayList ();

Long interval = Long
. valueof (Appproperties.getproperty ("Ldap.interval"))
. Longvalue ();
Timer timer = new timer ();
Timer.schedule (New TimerTask () ... {

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.