连接到使用java进行简单身份验证的ldap服务器时出错

时间:2017-02-10 18:53:05

标签: java authentication ldap connection

以下是我的代码片段:

public class CheckingUsers 
{   
public static void main(String[] args) throws NamingException, LoginException 
{
    String URL = "ldap://myhostURL:389";
    String ldapServerSearchBase = "DC=abc,DC=xyz,DC=pqr"; 
    String principal = "CN=myCN,OU=PEOPLE,DC=abc,DC=xyz,DC=pqr";

    Hashtable<String, Object> env = new Hashtable<String, Object>();
    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, principal);
    env.put(Context.SECURITY_CREDENTIALS, pswd);
        DirContext ctx = new InitialDirContext(env);
        System.out.println("connected");
        System.out.println(ctx.getEnvironment());

        // some stuff

        ctx.close();
}
}

我是新手,我在执行代码时收到此消息。请帮忙

enter image description here

当我停止执行时,我收到以下消息:

enter image description here

0 个答案:

没有答案