Simplest Java API (and CLI) for authenticating and searching in Active Directory
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Active Directory Lookup

Active Directory Lookup is an extremely simple Java API to access MS Active Directory for common tasks like user authentication and search. This lightweight library does not depend on any other library (No transitive dependencies) and is merely 17Kb in size. It also provides a minimal CLI for quick operations.

Build Status

Quick Start

Assuming we know the values of these variables

String domain;              // e.g.
String url;                 // e.g. ldap:// or ldap://
String searchBase;          // e.g. dc=acme,dc=org
String username;            // e.g. johndoe
String password;            // e.g. password

Authenticating with Active Directory

authenticator = new ActiveDirectoryAuthenticator(domain, url); // check out other constructors
authenticator.authenticate(username, password);

Searching in Active Directory

searcher = new SimpleActiveDirectorySearcher(url, domain, username, password, searchBase);


Building LdapContext

LdapContext ldapContext = ActiveDirectoryAuthenticator
                .getLdapContext(url, domain, username, password);


The built library can be consumed directly from jitpack repo

Using Gradle

Add this at the top of build.gradle

allprojects {
    repositories {
        maven { url '' }

Add/merge the dependency in the dependencies section

dependencies {
    compile 'com.github.kdabir:active-directory-lookup:1.0.2'

Using Maven

Add this to the pom.xml


Add this to the dependencies section within pom.xml


API Documentation

Browse the JavaDoc for details. The key methods to look out for are:

Building Locally

The project is built and packaged using Gradle.

Unit Testing

gradle test

Unit tests do not depend on any Active Directory instance and hence can be run without any configuration whatsoever.

Integration Testing

gradle integrationTests

You need to set the in the root of the project with the right configuration set in order to run Integration Tests.

Installing to local Maven repo

gradle publishToMavenLocal

This make's the jar available in you local maven repository for usage.

References :

Finding configuration

nslookup -type=srv _ldap._tcp.DOMAINNAME