X-tremely powerful Active Directory interface for php

0.3.4 2016-06-06 08:59 UTC


The AD-X library aims to provide an easy-to-use, object-oriented and powerful tool to work with Active Directory and related components, like Exchange.


The important ones

  • An understandable, object-oriented API to work with Active Directory
  • Automatic data conversion - with this library, you won't encounter a value that has to be converted to something else before you can work with it in php ( like unicodePwd or lastLogonTimestamp ) - you simply use the values and the library will take care of the conversion
  • User management / Microsoft Exchange mailbox management ( yes, you can create Exchange mailboxes / mail users with this! )
  • Support for paged searches
  • Support for referrals - useful if you operate on multiple domains in a forest
  • TLS or SSL encryption support
  • Directory Schema caching allows to perform checks, validations and provide guidance before you even attempt to modify anything on the server
  • Simple change tracking on your directory server
  • Selectors - a simple and elegant way to retrieve objects

The nice to have ones

  • ldap v3 protocol support
  • Namespaced classes to prevent collisions
  • Exceptions-based error handling
  • Autoloading support via Composer
  • Object-to-json conversion for easy integration with your front-end
  • Optional simple ldap query builder




Via Composer:

This will install the latest stable release:
composer require alaneor/ad-x:dev-master ( visit Packagist for list of all available versions )

Post-installation ( optional, but strongly recommended ) :

Generate the schema cache:

Create a new php script with the following contents, providing relevant information like domain and your domain credentials:

    include './vendor/autoload.php'; // Include Composer's autoloader

    $link = new ADX\Core\Link( '', 389 ); // Connect to server on default port
    $link->bind( '', 'password' ); // Authenticate to the server
    ADX\Core\Schema::build( $link ); // Build the local schema cache ( takes some time, go get a coffee )

A future release will include a wizard-like script to guide you through the process right after installation.

Depending on the stability of your Active Directory environment, you might need to re-build the schema cache occasionally, especially after upgrading to a newer Active Directory functional level or after installing new directory-related components, like MS Exchange, OCS Services or similar.


Documentation is currently available for the API only, but it includes a lot of examples and explanations. I recommend that you read the documentation in the following order:

  • Link : How to connect to the directory and perform authentication
  • Task : How to search the directory and retrieve data
  • Object : How to work with retrieved objects and read/manipulate its attributes
  • Attribute : How to manipulate individual attributes and read/manipulate its values
  • User : How to work with users and manage Exchange mailboxes / mail users

Read online: API documentation

Generate the documentation locally:

  1. Download the library
  2. Install the dependencies using Composer:
composer install --dev
  1. Generate the API documentation using ApiGen ( installed by Composer ):
php ./vendor/bin/apigen.php
  1. Generated documentation will be available at ./docs/www/index.html

Known limitations

  • The ldap v2 protocol is not supported and never will be. Pull requests to provide backwards-compatibility will be refused.
  • The library has been built specifically for Active Directory. Compatibility with standards-based ldap servers like OpenLDAP is likely broken. I have no plans to address this at the moment but a future release might make such thing possible.
  • Unit tests are missing completely. I realise this might be a serious issue for future development and plan to address this with a future update. Any help with writing tests is much appreciated.

Future to-dos

  • Improve the API documentation
  • Provide "helper" classes to simplify working with computers, groups, contacts etc.
  • Write unit tests
  • Write tutorials

Found an issue / have idea?

Please submit issues and ideas to the Github's issue tracker.

Contributing rules will be provided in a future update - for now, please try to match the programming style currently used in the code when submitting pull requests.


This software is licensed under the BSD (3-Clause) License. See the LICENSE file for more information.


If you like this project and enjoy using it, feel free to spread the word about it wherever you wish.

You may also consider donating.

Via Flattr:

Flattr this