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"));

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

SearchRequest request = new SearchRequest();
SearchRequestPropertySource srSource = new SearchRequestPropertySource(request, props);
srSource.initialize();

SearchOperation search = new SearchOperation(connectionFactory);
SearchResponse response = SearchOperation.execute(connectionFactory, request);