environment.setProperty( "java.naming.security.principal", "uid=admin,ou=system" );
if ( password != null )
{
environment.setProperty( "java.naming.security.credentials", password );
}
MutableServerStartupConfiguration configuration = new MutableServerStartupConfiguration();
configuration.setWorkingDirectory( basedir );
configuration.setAllowAnonymousAccess( true );
//configuration.setEnableNtp( false );
//configuration.setEnableKerberos( false );
//configuration.setEnableChangePassword( false );
LdapConfiguration config = new LdapConfiguration();
config.setIpPort( port );
configuration.setLdapConfiguration( config );
configuration.setEnableNetworking( enableNetworking );
configuration.setSynchPeriodMillis( 100 );
if ( configuration.getPartitionConfigurations() == null || ( configuration.getPartitionConfigurations() != null
&& configuration.getPartitionConfigurations().isEmpty() ) )
{
configuration.setPartitionConfigurations( partitionConfigurations );
}
Properties env = new Properties();
env.setProperty( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
if ( password != null )
{
env.setProperty( Context.SECURITY_CREDENTIALS, password );
}
env.setProperty( Context.SECURITY_AUTHENTICATION, "simple" );
env.setProperty( Context.PROVIDER_URL, "ou=system" );
env.setProperty( Context.INITIAL_CONTEXT_FACTORY, ServerContextFactory.class.getName() );
env.putAll( configuration.toJndiEnvironment() );
InitialDirContext context = new InitialDirContext( env );
//Attributes inetAttributes = context.getAttributes( "cn=inetorgperson,ou=schema" );
//inetAttributes.remove( "m-disabled" );