Well this my java code that allows me to connect to the ldap server.
public static Hashtable getConnexion()
{
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://localhost:10389");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
env.put(Context.SECURITY_CREDENTIALS, "secret");
return env;
}
thanks
If the LDAP client is standalone, it could be configured in several ways:
Use the UnboundID LDAP SDK
LDAPCommandLineToolclass and specify arguments to the program. For example, if the name of the class containing themainmethod wassamplecode.MyLdapConnectionClass:The UnboundID LDAP SDK
LDAPCommandLineToolclass handles all these types of command line arguments automatically, for example:--hostname(or-h) for the hostname--port(or-p) for the port--useSSLor--useStartTLS)The
LDAPCommandLineToolclass inherits a methodgetConnection()which establishes a connection to the server specified by those command line arguments.or specify the name of a properties file and parse the properties file using Apache Commons Configuration or the
load()method ofjava.util.properties.Either way, JNDI should not be used for new code. Use the UnboundID LDAP SDK instead.
see also