[débutante] JNDI ldap
auderyu
-
bigoliver -
bigoliver -
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?
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?
A voir également:
- [débutante] JNDI ldap
- Client ldap windows - Télécharger - Édition & Programmation
- Ldap tool box - Télécharger - Récupération de données
- Tarifs freelance debutante ? - Forum Graphisme
- Problème freeradius + ldap ✓ - Forum Linux / Unix
- Débutante dans GanttProject - Problème sous-tâche - Forum Gestion de projet
1 réponse
Salut,
Surement tu as déjà résolu ce problème vu la date. Mais pour ceux qui passeront par là, voici les causes possibles:
1 - Ton serveur LDAP ne tourne pas.
2 - Ton serveur LDAP n'écoute pas sur le port 389
3 - Impossible de se connecter à l'ordinateur sur lequel est installé le serveur LDAP(dans le cas où ce n'est pas la machine locale)
Hope that it will be useful for someone.
Surement tu as déjà résolu ce problème vu la date. Mais pour ceux qui passeront par là, voici les causes possibles:
1 - Ton serveur LDAP ne tourne pas.
2 - Ton serveur LDAP n'écoute pas sur le port 389
3 - Impossible de se connecter à l'ordinateur sur lequel est installé le serveur LDAP(dans le cas où ce n'est pas la machine locale)
Hope that it will be useful for someone.