CreateLdapServer serverAnnotation = createProviderMethod.getAnnotation( CreateLdapServer.class );
consumerServer = ServerAnnotationProcessor.instantiateLdapServer( serverAnnotation, provDirService, 0 );
SyncReplConsumer syncreplClient = new SyncReplConsumer();
final SyncreplConfiguration config = new SyncreplConfiguration();
config.setProviderHost( "localhost" );
config.setPort( 16000 );
config.setReplUserDn( "uid=admin,ou=system" );
config.setReplUserPassword( "secret".getBytes() );
config.setUseTls( false );
config.setBaseDn( "dc=example,dc=com" );
config.setRefreshInterval( 1000 );
syncreplClient.setConfig( config );
List<ReplicationConsumer> replConsumers = new ArrayList<ReplicationConsumer>();
replConsumers.add( syncreplClient );
consumerServer.setReplConsumers( replConsumers );
Runnable r = new Runnable()
{
public void run()
{
try
{
consumerServer.start();
DirectoryService ds = consumerServer.getDirectoryService();
Dn configDn = new Dn( ds.getSchemaManager(), "ads-replProviderId=localhost,ou=system" );
config.setConfigEntryDn( configDn );
Entry provConfigEntry = new DefaultEntry( ds.getSchemaManager(), configDn );
provConfigEntry.add( "objectClass", "ads-replConsumer" );
provConfigEntry.add( "ads-replConsumerId", "localhost" );
provConfigEntry.add( "ads-searchBaseDN", config.getBaseDn() );
provConfigEntry.add( "ads-replProvHostName", config.getProviderHost() );
provConfigEntry.add( "ads-replProvPort", String.valueOf( config.getPort() ) );
provConfigEntry.add( "ads-replAliasDerefMode", config.getAliasDerefMode().getJndiValue() );
provConfigEntry.add( "ads-replAttributes", config.getAttributes() );
provConfigEntry.add( "ads-replRefreshInterval", String.valueOf( config.getRefreshInterval() ) );
provConfigEntry.add( "ads-replRefreshNPersist", String.valueOf( config.isRefreshNPersist() ) );
provConfigEntry.add( "ads-replSearchScope", config.getSearchScope().getLdapUrlValue() );
provConfigEntry.add( "ads-replSearchFilter", config.getFilter() );
provConfigEntry.add( "ads-replSearchSizeLimit", String.valueOf( config.getSearchSizeLimit() ) );
provConfigEntry.add( "ads-replSearchTimeOut", String.valueOf( config.getSearchTimeout() ) );
provConfigEntry.add( "ads-replUserDn", config.getReplUserDn() );
provConfigEntry.add( "ads-replUserPassword", config.getReplUserPassword() );
consumerSession = consumerServer.getDirectoryService().getAdminSession();
consumerSession.add( provConfigEntry );
}
catch( Exception e )