Hi iam new to LDAP, if i enter the wrong passward then also connecting to the server.to avoid that what i havt to do .can i use DC's instead of BaseDN in the URL .can any one of you help me to solve this problem .Advence thanKs
import javax.naming.directory.*;
import javax.naming.*;
import java.util.*;
public class auth {
public static void main(
String[] args)
{
String url= "ldap://165.164.60.222:389/DC=mycompany,DC=com";
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, url);
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "username");
env.put(Context.SECURITY_CREDENTIALS, "passward");
try {
DirContext ctx = new InitialDirContext(env);
}
catch(AuthenticationException aex) {
System.out.println("AuthenticationException"+aex);
}
catch (NamingException e) {
System.out.println("Naming Exception: " + e );
}
}
}