当配置一个应用程序设置时,显示进程的调试/输出总是有用的。例如。 javax.mail.Session
具有debug
和debugOutput
。InitialDirContext
/InitialLdapContext
/LdapCtxFactory
Java类的参数/ 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) {}
}
}
您可以将com.sun.jndi.ldap.connect.pool.debug
系统属性设置为all
,它应该提供所需的信息。
https://docs.oracle.com/javase/jndi/tutorial/ldap/connect/config.html