// The real entry under ou=sales
Attributes fooAttrs = getPersonAttributes( "real", "real" );
ctx.createSubcontext( "cn=real,ou=sales", fooAttrs );
// The alias under ou=engineering, pointing to the real entry
Attributes aliasAttrs = new BasicAttributes( true );
javax.naming.directory.Attribute aliasOC = new BasicAttribute( "objectClass" );
aliasOC.add( "top" );
aliasOC.add( "alias" );
aliasOC.add( "extensibleObject" );
aliasAttrs.put( aliasOC );
aliasAttrs.put( "cn", "alias" );
aliasAttrs.put( "aliasedObjectName", "cn=real,ou=sales,ou=system" );
ctx.createSubcontext( "cn=alias,ou=engineering", aliasAttrs );
// Delete the real entry first
ctx.destroySubcontext( "cn=real,ou=sales" );