简体   繁体   English

LDAP连接被拒绝错误?

[英]connection refused error with LDAP?

I am trying to run following program: 我正在尝试运行以下程序:

package jndi;

import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;


public class LDAPRead {

    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/o=jaydeetechnology");
        try{
            System.out.println("creating initial directory context");
            DirContext ctx = (DirContext) new InitialContext(env);
            System.out.println("search for john hunt");
            Attributes attrs = ctx.getAttributes("cn=John Hunt , ou=JayDeeTechnology");
            System.out.println("find the surname and print it");
            System.out.println("sn: "+attrs.get("sn").get());
            ctx.close();
        }catch(NamingException e){
            e.printStackTrace();
        }
    }

}

but I am getting 'Connection refused' error. 但我得到'拒绝连接'错误。 Could any one please help me if I am missing something? 如果我遗失了什么,请帮助我吗?

creating initial directory context
javax.naming.CommunicationException: localhost:389 [Root exception is java.net.ConnectException: Connection refused: connect]
    at com.sun.jndi.ldap.Connection.<init>(Connection.java:222)
    at com.sun.jndi.ldap.LdapClient.<init>(LdapClient.java:130)
    at com.sun.jndi.ldap.LdapClient.getInstance(LdapClient.java:1592)
    at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2664)
    at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:305)
    at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:187)
    at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:205)
    at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:148)
    at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:78)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:235)
    at javax.naming.InitialContext.initializeDefaultInitCtx(InitialContext.java:318)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:348)
    at javax.naming.InitialContext.internalInit(InitialContext.java:286)
    at javax.naming.InitialContext.<init>(InitialContext.java:211)
    at jndi.LDAPRead.main(LDAPRead.java:31)
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:383)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:245)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:232)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:377)
    at java.net.Socket.connect(Socket.java:539)
    at java.net.Socket.connect(Socket.java:488)
    at java.net.Socket.<init>(Socket.java:385)
    at java.net.Socket.<init>(Socket.java:199)
    at com.sun.jndi.ldap.Connection.createSocket(Connection.java:364)
    at com.sun.jndi.ldap.Connection.<init>(Connection.java:199)
    ... 14 more

I am using RSA 8.0 我使用的是RSA 8.0

From the Adobe LDAP Troubleshooting pages : 从Adobe LDAP疑难解答页面

Error: javax.naming.CommunicationException: [server]:[port] [Root exception is java.net.ConnectException: Connection refused: connect]

Cause: The port name you have specified for the LDAP/AD server is incorrect.

I'd say your using the wrong hostname, the wrong port number, or haven't started you LDAP installation on that server yet. 我会说你使用了错误的主机名,错误的端口号,或者还没有在那台服务器上启动LDAP安装。

Try looking in the LDAP server's logs, perhaps you can learn a bit more from there. 尝试查看LDAP服务器的日志,也许你可以从那里学到更多东西。

'Connection refused' has the same meaning here as everywhere else. “拒绝连接”与其他地方具有相同的含义。 Nothing was listening at the IP:port you tried to connect to. 没有什么东西在你试图连接的IP端口上侦听。 Either the service hadn't started or you got the IP or port wrong. 服务尚未启动或您的IP或端口错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM