【问题标题】:LDAP Java print debug outputLDAP Java 打印调试输出
【发布时间】:2020-02-15 15:16:27
【问题描述】:

当配置应用程序设置时,显示进程的调试/输出总是有用的。 例如。 javax.mail.SessiondebugdebugOutputInitialDirContext/InitialLdapContext/LdapCtxFactory Java 类的参数/API 是否类似?

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

附: 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】:

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

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

    【讨论】:

      猜你喜欢
      • 2021-12-22
      • 2011-06-26
      • 1970-01-01
      • 2011-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多