Bonjour,
Je commence à peine à apprendre le JNDI et j'ai fais ce code pour me connecter:
public static void main(String[] args) throws NamingException {
try {
Hashtable<String,String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL,"ldap://localhost:389");
env.put(Context.SECURITY_AUTHENTICATION,"sasl");
env.put(Context.SECURITY_PRINCIPAL, "cn=ldap-admin,dc=test-ldap,dc=net");
env.put(Context.SECURITY_CREDENTIALS, "ldap-admin");
Context ictx = new InitialContext(env);
NamingEnumeration<NameClassPair> e = ictx.list("cn=userA");
while (e.hasMore()) {
System.out.println("name : " + e.next().getName());
}
} catch (javax.naming.NamingException e){
System.err.println("Exception : " + e);
};
Et sa m'affiche l'erreur:
Exception : javax.naming.CommunicationException: localhost:389 [Root exception is java.net.ConnectException: Connection refused: connect]
Pouvez-vous m'aider?
