Skip to content
← Work

ldap-utility: LDAP integration in Java without the boilerplate

Open source Java library that reduces LDAP and Active Directory integration to a few lines, with object mapping and an in-memory server for tests.

Role
Design, development and release
Status
Published on Maven Central
Stack
Java, LDAP, Active Directory, Maven, JUnit
Licence
MIT
  • Distributed on Maven Central under the dev.matteuo:ldap-utility coordinate
  • LDAP searches with automatic mapping of results onto Java objects
  • User authentication against corporate directories
  • Bundled in-memory LDAP server, for tests that need no infrastructure
  • Public source code under the MIT licence

The problem

Almost every enterprise application eventually has to talk to a directory: authenticating people against Active Directory, reading groups and attributes, keeping records in sync. In Java this nearly always means rewriting the same code: opening a JNDI context, hand-assembling search filters, iterating over NamingEnumeration, pulling attributes out one by one, and remembering to close everything even when something fails.

It is tedious, repetitive code, and surprisingly easy to get wrong. Worse, it tends to be hard to test: verifying it requires a real directory, and that alone is enough to ensure most projects never test it at all.

Design decisions

Declarative mapping instead of manual extraction. A search returns a list of typed Java objects directly, not an attribute structure to rummage through. Callers describe what they want; translating LDAP attributes into object fields stays an internal detail.

An in-memory LDAP server inside the library. This is the decision I consider most important in the project. Making tests runnable without external infrastructure changes the odds that those tests get written at all: if exercising the code requires a reachable corporate directory, it simply won’t be exercised.

Class generation from actual attributes. Every directory has its own schema. Rather than imposing a rigid data model, the library generates the Java source matching the attributes actually present, cutting the manual work during adoption.

A deliberately small public surface. Search, authentication, generation. Nothing else. A utility library that grows without discipline becomes a framework, and a framework has to be maintained: I would rather it do few things and keep doing them the same way for years.

The artefact

The library is distributed on Maven Central, the official registry of the Java ecosystem. Publishing there is not a free-for-all upload: it requires verified ownership of the domain used as groupId, GPG-signed artefacts, and compliance with requirements on metadata, sources and javadoc. That barrier is worth mentioning, because it says more about release discipline than any download count would.

The code is public under the MIT licence: anyone can read it, verify it, run it in production and change it.

Technical cookies

Always on

Essential for the site to work and to remember your cookie choice. They require no consent and cannot be disabled.

Google Analytics, to understand which content is useful. They involve a transfer of data to the United States. Disabled until you allow them.

Marketing cookies

None in use

I use none. The category is listed for transparency and would only ever be enabled with your consent.