About LDAP Syntaxes and backward compatibility…

In the LDAP information model, a syntax constrains the structure and format of attribute values. OpenDJ defines and implements a large number of syntaxes (you can discover them by reading the ldapSyntaxes attribute from the cn=Schema entry).

But infrequently, we receive enquiries on an obscure and non standard syntax, often in the form of “I’m having an error importing schema from this or that legacy directory server”, with an error message that ends with “No such syntax is configured for use in the Directory Server”.

As syntaxes are constraining the structure and format of attribute values, they are implemented as code, specifically Java code in OpenDJ. It’s possible to implement new syntaxes by implementing the org.opends.server.api.AttributeSyntax abstract class, and installing the classes or the JAR in OpenDJ classpath. But often, it’s easier and more convenient to define a syntax by configuration, and OpenDJ offers 3 possibilities to define new syntaxes. In term of backward compatibility, I will only focus on the 2 main ones, by substitution and by pattern (the 3rd one allows to define enumeration of values).

With OpenDJ, you can define a new syntax by configuration and delegating the contraints to an already implemented syntax. A simple example is the URI syntax (which was defined is some very old schema with the OID  1.3.6.1.4.1.4401.1.1.1). A URI is really an ASCII string, and it might be sufficient to accept attributes with URI syntax to verify that all characters are pure ASCII. The standard syntax for ASCII strings is IA5String aka 1.3.6.1.4.1.1466.115.121.1.15.

ldapSyntaxes: ( 1.3.6.1.4.1.4401.1.1.1 DESC ‘URI’ X-SUBST ‘1.3.6.1.4.1.1466.115.121.1.15’ )

Insert the above line in the schema LDIF file before the attributeTypes, and you’re done.

The other option is to define the syntax as a pattern, using regular expressions. This could be better when willing to enforce additional constraints on an URI, for example, verifying that the URI is an LDAP one.

ldapSyntaxes: ( 999.999.999.1 DESC 'LDAP URI Syntax' X-PATTERN '^ldap://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]' )

So the next time you are trying to import some legacy schema to the OpenDJ directory server, and you have an error due to missing syntaxes, you know what to do to quickly resolve the problem.

4 thoughts on “About LDAP Syntaxes and backward compatibility…

  1. Stefano 26 January 2017 / 15:38

    Hello there, I’ve tried to add an entry like

    ldapSyntaxes: ( 999.999.999.1 DESC ‘LDAP URI Syntax’ X-PATTERN ‘^ldap://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]’ )

    and a new attribute like:

    dn: cn=schema
    changetype: modify
    add: attributetypes
    attributetypes: ( 999.999.999.2 NAME ‘example-attr-enum’ SYNTAX
    999.999.999.1 )

    in OpenDJ 3.0.0
    but if I use 999.999.999.1 as OID it says “No such syntax is configured for use in the Directory Server”, if I use a string like “syntax-rule-oid” instead of classic OID X.Y.Z… when OpenDJ starts it does not have that OID in the schema, and the also the attribute definition is not present.

    I gived up.

    • Ludo 26 January 2017 / 15:49

      I believe you are experimenting an issue with extending the schema in OpenDJ 3.0.0. This problem was fixed in the ForgeRock maintenance releases as well as the master code repository.

      • Stefano Coletta 26 January 2017 / 16:04

        Good to know! Thank you for your *instant* reply 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s