Properties

In order to support various configuration formats Ldaptive provides the ability to configure its objects with Properties. Each property identifies a method which is reflectively invoked with the value.

org.ldaptive.ldapUrl=ldap://directory.ldaptive.org
org.ldaptive.baseDn=dc=ldaptive,dc=org
org.ldaptive.connectTimeout=3000
org.ldaptive.useStartTLS=true
java.util.Properties props = new java.util.Properties();
props.load(new FileInputStream("/path/to/ldap.properties"));

SearchExecutor searchExecutor = new SearchExecutor();
SearchRequestPropertySource srSource = new SearchRequestPropertySource(searchExecutor, props);
srSource.initialize();

DefaultConnectionFactory connectionFactory = new DefaultConnectionFactory();
DefaultConnectionFactoryPropertySource dcfSource = new DefaultConnectionFactoryPropertySource(connectionFactory, props);
dcfSource.initialize();

SearchResult result = searchExecutor.search(connectionFactory, "(mail=dfisher@ldaptive.org)").getResult();