LDAP Attribute values and attributes are not ordered

Avoid the common mistake of expecting attribute values in an LDAP search result to be ordered. The LDAP standard explicitly notes that attributes and attribute values are not ordered. Too often, programmers expect data to be ordered, that is, for the order that data is returned from a search request to be repeatable. If the order is important, a directory server such as UnboundID’s Directory Server supports the server-side sort request control.

The ordering also applies to the case where software expects that the order attributes are returned is the same as the order in which they are listed. For example, if the following command is executed in a shell or perl script:

ldapsearch [connection options] search-filter attr1 attr2 attr3

programmers must not expect that the attributes are returned in the order

attr1 attr2 attr3

Further, the order of attribute options is not significant, for example:

uid;lang-de;lang-en: value

is the same as:

uid;lang-en;lang-de: value

It is telling that the standard specifically mentions that attribute values (and partial attribute values) are not ordered, rather than leaving it up to the vendor. Several times per year a case comes up where a programmer written some code that is dependent on the ordering of attributes and this code suddenly – for no apparent reason – stops working. The code “used to work” or “has worked for years”. The reason was that the code was dependent on the ordering of attributes, attribute values, return order, or entry ordering. it is also important to note that the ordering is not repeatable, that is, the ordering could conceivably change from one search request to the next.


About Terry Gardner

Terry Gardner was a leading directory services architect with experience with many large scale directory services installations and messaging server installations, and was a Subject Matter Expert in the field of Directory Services and Solaris (operating system) performance. Mr. Gardner also participated in the open-source software community. Mr. Gardner passed away in December, 2013.
This entry was posted in computing, technology and tagged , , , . Bookmark the permalink.

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 )

Google photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s