LDAP Java打印调试输出

问题描述 投票:0回答:1

当配置一个应用程序设置时,显示进程的调试/输出总是有用的。例如。 javax.mail.Session具有debugdebugOutputInitialDirContext/InitialLdapContext/LdapCtxFactoryJava类的参数/ API是否与之相似?

我的目标是在LDAP连接出现问题时向用户提供调试信息。

P.S。 Java代码很简单:

    Properties properties = new Properties();
    properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    properties.put(Context.PROVIDER_URL,  domainController);
    properties.put(Context.SECURITY_AUTHENTICATION, "simple"); 
    properties.put(Context.SECURITY_PRINCIPAL, login);
    properties.put(Context.SECURITY_CREDENTIALS, password);

    //initializing active directory LDAP connection
    InitialDirContext dirContext = null;
    try {
        dirContext = new InitialDirContext(properties);
        System.out.println("OK!");
    } catch (NamingException e) {
        //ignore auth. exception
        System.out.println("Failed!!!");
        e.printStackTrace();
    }finally{
        if(dirContext != null)
            try {
                dirContext.close();
            } catch (NamingException e) {}
    }
}
java debugging active-directory ldap jndi
1个回答
0
投票

您可以将com.sun.jndi.ldap.connect.pool.debug系统属性设置为all,它应该提供所需的信息。

https://docs.oracle.com/javase/jndi/tutorial/ldap/connect/config.html

© www.soinside.com 2019 - 2024. All rights reserved.