If you have an LdapDN instance that you got back then just do a getUpName().  This returns the user provided form of the attributeType alias. 

If you do not have an LdapDN object or you're still getting back normalized names from getUpName(), then there is code in the OperationalAttributeInteceptor that does denormalization.  It denormalizes operational attributes.  You can grab this code and strip it out for your for own use.  Here's the link to the interceptor and below it the relavent code you need:


http://nouhe.notlong.com/


    public void denormalizeEntryOpAttrs( ServerEntry entry ) throws NamingException
{
if ( service.isDenormalizeOpAttrsEnabled() )
{
EntryAttribute attr = entry.get( SchemaConstants.CREATORS_NAME_AT );

if ( attr != null )
{
LdapDN creatorsName = new LdapDN( attr.getString() );

attr.clear();
attr.add( denormalizeTypes( creatorsName ).getUpName() );
}

attr = entry.get( SchemaConstants.MODIFIERS_NAME_AT );

if ( attr != null )
{
LdapDN modifiersName = new LdapDN( attr.getString() );

attr.clear();
attr.add( denormalizeTypes( modifiersName ).getUpName() );
}

attr = entry.get( ApacheSchemaConstants.SCHEMA_MODIFIERS_NAME_AT );

if ( attr != null )
{
LdapDN modifiersName = new LdapDN( attr.getString() );

attr.clear();
attr.add( denormalizeTypes( modifiersName ).getUpName() );
}
}
}


/**
* Does not create a new DN but alters existing DN by using the first
* short name for an attributeType definition.
*
* @param dn the normalized distinguished name
* @return the distinuished name denormalized
* @throws NamingException if there are problems denormalizing
*/

public LdapDN denormalizeTypes( LdapDN dn ) throws NamingException
{
LdapDN newDn = new LdapDN();

for ( int ii = 0; ii < dn.size(); ii++ )
{
Rdn rdn = dn.getRdn( ii );
if ( rdn.size() == 0 )
{
newDn.add( new Rdn() );
continue;
}
else if ( rdn.size() == 1 )
{
String name = atRegistry.lookup( rdn.getNormType() ).getName();
String value = (String)rdn.getAtav().getNormValue();
newDn.add( new Rdn( name, name, value, value ) );
continue;
}

// below we only process multi-valued rdns
StringBuffer buf = new StringBuffer();

for ( Iterator<AttributeTypeAndValue> atavs = rdn.iterator(); atavs.hasNext(); /**/ )
{
AttributeTypeAndValue atav = atavs.next();
String type = atRegistry.lookup( rdn.getNormType() ).getName();
buf.append( type ).append( '=' ).append( atav.getNormValue() );

if ( atavs.hasNext() )
{
buf.append( '+' );
}
}

newDn.add( new Rdn(buf.toString()) );
}

return newDn;
}
 

On Mon, Aug 11, 2008 at 2:01 PM, Emmanuel Lecharny <elecharny@gmail.com> wrote:
Hammond, Steve wrote:
I have java code interfacing with ADS by calling
PartitionNexusProxy.search(searchOpContext).  Most DN's come back
"readable".  But sometimes some of them come back with OIDs (I think
that is normalized?)

 
I have a dn 2.5.4.11=local,2.5.4.11=users

Is there an existing function that can translate that to
ou=local,ou=users?
 

if you have your DN stored into a LdapDN object, then assuming you have access to the registries :

dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );


That should do the trick.


--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org





--
Microsoft gives you Windows, Linux gives you the whole house ...