{
DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
// Create container
Attributes container = new BasicAttributes( true );
Attribute containerOcls = new BasicAttribute( SchemaConstants.OBJECT_CLASS_AT );
containerOcls.add( SchemaConstants.TOP_OC );
containerOcls.add( SchemaConstants.ORGANIZATIONAL_UNIT_OC );
container.put( containerOcls );
container.put( SchemaConstants.OU_AT, "Fruits" );
String containerRdn = "ou=Fruits";
DirContext containerCtx = ctx.createSubcontext( containerRdn, container );
// Create entry
Attributes entry = new BasicAttributes( true );
Attribute entryOcls = new BasicAttribute( SchemaConstants.OBJECT_CLASS_AT );
entryOcls.add( SchemaConstants.TOP_OC );
entryOcls.add( SchemaConstants.ORGANIZATIONAL_UNIT_OC );
entry.put( entryOcls );
entry.put( SchemaConstants.OU_AT, "favorite" );
String entryRdn = "ou=favorite";
containerCtx.createSubcontext( entryRdn, entry );
// Create alias ou=bestFruit,ou=Fruits to entry ou=favorite,ou=Fruits
String aliasedObjectName = entryRdn + "," + containerCtx.getNameInNamespace();
Attributes alias = new BasicAttributes( true );
Attribute aliasOcls = new BasicAttribute( SchemaConstants.OBJECT_CLASS_AT );
aliasOcls.add( SchemaConstants.TOP_OC );
aliasOcls.add( SchemaConstants.EXTENSIBLE_OBJECT_OC );
aliasOcls.add( SchemaConstants.ALIAS_OC );
alias.put( aliasOcls );
alias.put( SchemaConstants.OU_AT, "bestFruit" );
alias.put( SchemaConstants.ALIASED_OBJECT_NAME_AT, aliasedObjectName );
String rdnAlias = "ou=bestFruit";
containerCtx.createSubcontext( rdnAlias, alias );