h2. Rdn A *RDN*, or *R{*}elative *D{*}istinguished *N{*}ame is a part of a *[Dn]*. It can be empty, but usually contains one *[Ava]*, but can have more than one. It's used to qualify an entry in the *DIT*, assuming that every element of a *RDN* must be present in the entry. It's important to understand that a *RDN* represents the entry, by naming it. This class can be schema aware, as soon as we inject a *[SchemaManager (...)] into it while creating an instance. It's an immutable class, and it implements the _externalizable_ interface. {tip:title=Info} The Rdn class is immutable. {tip} h4. Basic examples Let's see some examples : *{+}Simple RDN, not schema aware :+* {code} // Create a simple Rdn Rdn rdn = new Rdn( "CN = This is a Test " ); System.out.println( "toString : " + rdn.toString() ); System.out.println( "User Provided name : " + rdn.getName() ); System.out.println( "Normalized name : " + rdn.getNormName() ); {code} This code produces the output : {code} toString : 'CN = This is a Test ' User Provided name : 'CN = This is a Test ' Normalized name : 'cn=This is a Test' {code} Note that the normalized form has a lower cased *[AttributeType (...)]* and that the value's heading and trailing spaces have been removed. *{+}Simple RDN, schema aware :+* {code} // Create a schema aware Rdn Rdn rdn = new Rdn( schemaManager, "CN = This is a Test " ); System.out.println( "toString : " + rdn.toString() ); System.out.println( "User Provided name : " + rdn.getName() ); System.out.println( "Normalized name : " + rdn.getNormName() ); {code} This code produces the output : {code} toString : 'CN = This is a Test ' User Provided name : 'CN = This is a Test ' Normalized name : '2.5.4.3=this is a test' {code} Now, the normalized form uses the *[Oid]* instead of a *[AttributeType (...)]* ID, and the value is normalized accordingly to the *CN* equality matching rule. h4. Creating a RDN We can create a standard *RDN* or a schema aware *RDN*. It's just a matter to pass a *[SchemaManager (...)]* as a parameter. Here is an example of creation of a normal and schema aware ¬*RDN* : {code} Rdn normalRdn = new Rdn( "CN = a simple RDN" ); Rdn schemaAwareRdn = new Rdn( schemaManager, "CN = a schema aware RDN" ); {code} It's also possible to create a *RDN* by passing the *[AttributeType (...)]* and the value as two parameters : {code} Rdn normalRdn = new Rdn( "CN", "a simple RDN" ); Rdn schemaAwareRdn = new Rdn( schemaManager, "CN", "a schema aware RDN" ); {code} h4. Multiple RDN A *RDN* can contain more than one *[Ava]*. In order to access the *[Ava]s*, we can use an iterator : {code} Rdn rdn = new Rdn( "cn=John + sn=Doe" ); for ( Ava ava : rdn ) { System.out.println( ava.toString() ); } {code} produces this output : {code} cn=John sn=Doe {code} However, there is no guarantee whatsoever about the order a user will get back the *[Ava]* when iterating through them. A user can also request the first *[Ava]* by calling the _getAva()_ method : {code} Rdn rdn = new Rdn( "cn=John + sn=Doe" ); System.out.println( rdn.getAva() ); {code} produces this output : {code} cn=John {code} h4. Miscellaneous methods It's possible to make a non schema aware *RDN* by passing it a *[SchemaManager (...)]*. In order to know if a *RDN* is schema aware, we can call the _isSchemaAware()_ method. Here is some example where those methods are used : {code} Rdn rdn = new Rdn( "cn=John" ); System.out.println( "'" + rdn + "' is schema aware : " + rdn.isSchemaAware() ); System.out.println( "Applying a schemaManager to '" + rdn + "'"); rdn.applySchemaManager( schemaManager ); System.out.println( "'" + rdn + "' is schema aware : " + rdn.isSchemaAware() ); {code} produces the output : {code} 'cn=John' is schema aware : false Applying a schemaManager to 'cn=john' 'cn=John' is schema aware : true {code}