Return-Path: Delivered-To: apmail-directory-dev-archive@www.apache.org Received: (qmail 6839 invoked from network); 11 Aug 2008 23:30:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Aug 2008 23:30:55 -0000 Received: (qmail 32975 invoked by uid 500); 11 Aug 2008 23:30:54 -0000 Delivered-To: apmail-directory-dev-archive@directory.apache.org Received: (qmail 32937 invoked by uid 500); 11 Aug 2008 23:30:54 -0000 Mailing-List: contact dev-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Apache Directory Developers List" Delivered-To: mailing list dev@directory.apache.org Received: (qmail 32926 invoked by uid 99); 11 Aug 2008 23:30:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Aug 2008 16:30:54 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,NORMAL_HTTP_TO_IP,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of akarasulu@gmail.com designates 209.85.217.14 as permitted sender) Received: from [209.85.217.14] (HELO mail-gx0-f14.google.com) (209.85.217.14) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Aug 2008 23:29:56 +0000 Received: by gxk7 with SMTP id 7so487391gxk.1 for ; Mon, 11 Aug 2008 16:29:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:in-reply-to:mime-version:content-type:references :x-google-sender-auth; bh=QIXc+Gw3+QNs7+TlJzAtrQh3W92x5rE+36jwkguYuWQ=; b=D08B6bWto3izHd5S6+ZzlElyy0YiPitRusB1ZYfDr1STpZO3jqdosF4pDBKPDDftyg VJfL8xcwwdrcvYUfCViN3OfuT7jX53pCsU8XLOZSWX22r1ztm1LVRE85ltXyyoXZmeHJ nRS8APklRwDDiMa03UGjIRGJ1JObBeiImA5sQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:in-reply-to:mime-version :content-type:references:x-google-sender-auth; b=W1W0C0B7OleTEELrZVYXHEr6gf/x4EVKuNsE239eptRspsaYuu7JNyeCnJssxOG4/Y 0qDbuWnq3NzAOK2wxDCDE1ffRvNBx2JsJehbYHqtGthCu38JvqWmIZ3PNosMtrjUAbzI o8YQDYDZwZhZGwHMw79CucdzJfeabdkjVeXPs= Received: by 10.151.110.9 with SMTP id n9mr4474ybm.225.1218497363292; Mon, 11 Aug 2008 16:29:23 -0700 (PDT) Received: by 10.150.200.1 with HTTP; Mon, 11 Aug 2008 16:29:23 -0700 (PDT) Message-ID: Date: Mon, 11 Aug 2008 19:29:23 -0400 From: "Alex Karasulu" Sender: akarasulu@gmail.com To: "Apache Directory Developers List" , elecharny@nextury.com Subject: Re: [ApacheDS] is there an easy function to convert OIDs? In-Reply-To: <48A07E61.5090507@gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_109152_17300449.1218497363399" References: <48A07E61.5090507@gmail.com> X-Google-Sender-Auth: 9633c1f3491558e5 X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_109152_17300449.1218497363399 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 =3D entry.get( SchemaConstants.CREATORS_NAM= E_AT ); *if* ( attr !=3D *null* ) { LdapDN creatorsName =3D *new* LdapDN( attr.getString() ); attr.clear(); attr.add( denormalizeTypes( creatorsName ).getUpName() ); } attr =3D entry.get( SchemaConstants.MODIFIERS_NAME_AT ); *if* ( attr !=3D *null* ) { LdapDN modifiersName =3D *new* LdapDN( attr.getString() ); attr.clear(); attr.add( denormalizeTypes( modifiersName ).getUpName() ); } attr =3D entry.get( ApacheSchemaConstants.SCHEMA_MODIFIERS_NAME= _AT ); *if* ( attr !=3D *null* ) { LdapDN modifiersName =3D *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 =3D *new* LdapDN(); *for* ( *int* ii =3D 0; ii < dn.size(); ii++ ) { Rdn rdn =3D dn.getRdn( ii ); *if* ( rdn.size() =3D=3D 0 ) { newDn.add( *new* Rdn() ); *continue*; } *else* *if* ( rdn.size() =3D=3D 1 ) { String name =3D atRegistry.lookup( rdn.getNormType() ).getN= ame(); String value =3D (String)rdn.getAtav().getNormValue(); newDn.add( *new* Rdn( name, name, value, value ) ); *continue*; } *// below we only process multi-valued rdns * StringBuffer buf =3D *new* StringBuffer(); *for* ( Iterator atavs =3D rdn.iterator(); atavs.hasNext(); */**/* ) { AttributeTypeAndValue atav =3D atavs.next(); String type =3D atRegistry.lookup( rdn.getNormType() ).getN= ame(); buf.append( type ).append( *'=3D'* ).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 wro= te: > 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=3Dlocal,2.5.4.11=3Dusers >> >> Is there an existing function that can translate that to >> ou=3Dlocal,ou=3Dusers? >> >> > > 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=E9charny > www.iktek.com > directory.apache.org > > > --=20 Microsoft gives you Windows, Linux gives you the whole house ... ------=_Part_109152_17300449.1218497363399 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
If you have an LdapDN instance that you got back then just= do a getUpName().  This returns the user provided form of the attribu= teType 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 <=
font color=3D"#a020f0">void denormalizeEntryOpAttrs( ServerEntry=
 entry ) throws NamingException
{
if ( service.isDenor= malizeOpAttrsEnabled() )
{
EntryAttribute attr = =3D entry.get( SchemaConstants.CREATORS_NAME_AT );

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

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

attr =3D entry.get( SchemaCons= tants.MODIFIERS_NAME_AT );

if ( attr !=3D null<= /b> )
{
LdapDN modifiersName =3D new LdapDN( attr.getString() );

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

attr =3D entry.get( ApacheSchemaConstants.= SCHEMA_MODIFIERS_NAME_AT );

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

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


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

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

for= ( int ii =3D 0; ii < dn.size(); i= i++ )
{
Rdn rdn =3D dn.getRdn( ii );
if
( rdn.size() =3D=3D 0 )
{=
newDn.add( new Rd= n() );
continue;
= }
else if ( rdn.size() =3D=3D 1 )
{
= String name =3D atRegistry.lookup( rdn.getNormType() ).getNa= me();
String value =3D (String)rdn.getAtav().getNormValue();
= newDn.add( new Rdn( n= ame, name, value, value ) );
= continue;
}

// below we onl= y process multi-valued rdns
StringBuffer buf =3D = new StringBuffer();

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

if ( atavs.hasNext() )
{
buf.appen= d( '+' );
= }
}

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

= return newDn;
}
 

On Mon, Aug 11, 2008 at 2:0= 1 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<= br> "readable".  But sometimes some of them come back with OIDs = (I think
that is normalized?)

 
I have a dn 2.5.4.11=3Dlo= cal,2.5.4.11=3Dusers

Is there an existing function that can translate that to
ou=3Dlocal,ou=3Dusers?
 

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

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


That should do the trick.


--
--
cordialement, regards,
Emmanuel L=E9charny
www.iktek.com
directory.apache.= org





--
Microsoft gives = you Windows, Linux gives you the whole house ...
------=_Part_109152_17300449.1218497363399--