import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.ldap.InitialLdapContext;
import javax.naming.ldap.LdapContext;
public class LdapConnection {
public static void main(String[] args) {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL,"ldap://localhost:389");
try {
LdapContext ctx = new InitialLdapContext(env,null);
System.out.println("LDAP Connection Successful");
System.exit(0);
} catch (NamingException e) {
System.err.println("LDAP Notifications failure. " + e.getMessage());
System.exit(1);
}
}
}
No comments:
Post a Comment