PHPackages                             freedsx/ldap - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. freedsx/ldap

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

freedsx/ldap
============

A Pure PHP LDAP library

0.8.0(3y ago)157142.4k↓10.2%18[4 issues](https://github.com/FreeDSx/LDAP/issues)[3 PRs](https://github.com/FreeDSx/LDAP/pulls)2MITPHPPHP &gt;=7.1CI failing

Since Oct 23Pushed 1mo ago7 watchersCompare

[ Source](https://github.com/FreeDSx/LDAP)[ Packagist](https://packagist.org/packages/freedsx/ldap)[ Docs](https://github.com/FreeDSx/LDAP)[ RSS](/packages/freedsx-ldap/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (12)Versions (13)Used By (2)

FreeDSx LDAP [![](https://github.com/FreeDSx/LDAP/workflows/Analysis/badge.svg)](https://github.com/FreeDSx/LDAP/workflows/Analysis/badge.svg) [![](https://github.com/FreeDSx/LDAP/workflows/Build/badge.svg)](https://github.com/FreeDSx/LDAP/workflows/Build/badge.svg) [![codecov](https://camo.githubusercontent.com/67b56b62da72f005f19efea205c91b05dd2f5986e199e243e59f7720aba7a5f8/68747470733a2f2f636f6465636f762e696f2f67682f467265654453782f4c4441502f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/FreeDSx/LDAP)
=================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#freedsx-ldap---)

FreeDSx LDAP is a pure PHP LDAP library. It has no requirement on the core PHP LDAP extension. This library currently implements most client functionality described in [RFC 4511](https://tools.ietf.org/html/rfc4511) and some very limited LDAP server functionality. It also implements some other client features from various RFCs:

- Paging Control Support ([RFC 2696](https://tools.ietf.org/html/rfc2696))
- VLV Control Support ([draft-ietf-ldapext-ldapv3-vlv-09](https://www.ietf.org/archive/id/draft-ietf-ldapext-ldapv3-vlv-09.txt))
- Server Side Sort Control ([RFC 2891](https://tools.ietf.org/html/rfc2891))
- Password Modify Request ([RFC 3062](https://tools.ietf.org/html/rfc3062))
- String Representation of Search Filters ([RFC 4515](https://tools.ietf.org/search/rfc4515))
- SASL authentication / integrity layer support for certain mechanisms ([RFC 4513](https://tools.ietf.org/search/rfc4513))

It supports encryption of the LDAP connection through TLS via the OpenSSL extension if available.

Documentation
=============

[](#documentation)

- [LDAP Client](/docs/Client)
    - [Configuration](/docs/Client/Configuration.md)
    - [SASL Bind Authentication](/docs/Client/SASL-Bind-Authentication.md)
    - [General Usage](/docs/Client/General-Usage.md)
    - [Entries](/docs/Client/Entries.md)
    - [Operations](/docs/Client/Operations.md)
    - [Controls](/docs/Client/Controls.md)
    - [Searching and Filters](/docs/Client/Searching-and-Filters.md)
    - [Range Retrieval](/docs/Client/Range-Retrieval.md)
    - [DirSync](/docs/Client/DirSync.md)
- [LDAP Server](/docs/Server)
    - [Configuration](/docs/Server/Configuration.md)
    - [General Usage](/docs/Server/General-Usage.md)

Getting Started
===============

[](#getting-started)

Install via [composer](https://getcomposer.org/download/):

```
composer require freedsx/ldap
```

Use the LdapClient class and the helper classes:

```
use FreeDSx\Ldap\LdapClient;
use FreeDSx\Ldap\Operations;
use FreeDSx\Ldap\Search\Filters;

$ldap = new LdapClient([
    # Servers are tried in order until one connects
    'servers' => ['dc1', 'dc2'],
    # The base_dn is used as the default for searches
    'base_dn' => 'dc=example,dc=local'
]);

# Encrypt the connection prior to binding
$ldap->startTls();

# Bind to LDAP with a specific user.
$ldap->bind('user@example.local', '12345');

# Build up a LDAP filter using the helper methods
$filter = Filters::and(
    Filters::equal('objectClass', 'user'),
    Filters::startsWith('cn', 'S'),
    # Add a filter object based off a raw string filter...
    Filters::raw('(telephoneNumber=*)')
);
# Create a search operation to be used based on the above filter
$search = Operations::search($filter, 'cn');

# Create a paged search, 100 results at a time
$paging = $ldap->paging($search, 100);

while ($paging->hasEntries()) {
    $entries = $paging->getEntries();
    var_dump(count($entries));

    foreach ($entries as $entry) {
        echo "Entry: ".$entry->getDn().PHP_EOL;
    }
}
```

CRUD Operations:
================

[](#crud-operations)

- [Create](#create)
- [Read](#read)
- [Update](#update)
- [Delete](#delete)

Create
------

[](#create)

```
use FreeDSx\Ldap\Entry\Entry;
use FreeDSx\Ldap\Exception\OperationException;

# Create a new LDAP entry object
$entry = (new Entry('cn=foo,dc=domain,dc=local'))
   ->set('objectClass','top', 'group')
   ->set('sAMAccountName', 'foo');

# Create the entry with the LDAP client
try {
    $ldap->create($entry);
} catch (OperationException $e) {
    echo sprintf('Error adding entry (%s): %s', $e->getCode(), $e->getMessage()).PHP_EOL;
}
```

Read
----

[](#read)

```
# Use the read() method of the LDAP client to search for a specific entry.
# Optionally pass an array of attributes to select as the second argument.
$entry = $ldap->read('cn=foo,dc=domain,dc=local');

# Entry will be null if it doesn't exist
if ($entry) {
    echo $entry.PHP_EOL;
    var_dump($entry->toArray());
}
```

Update
------

[](#update)

```
use FreeDSx\Ldap\Exception\OperationException;

# Search for an entry object to get its current attributes / values
$entry = $ldap->read('cn=foo,dc=domain,dc=local');

# Add a value to an attribute
if (!$entry->get('telephoneNumber')) {
    $entry->add('telephoneNumber', '555-5555');
}
# Remove any values an attribute may have
if ($entry->has('title')) {
    $entry->reset('title');
}
# Delete a specific value for an attribute
if ($entry->get('ipPhone')->has('12345')) {
    $entry->delete('ipPhone', '12345');
}
# Set a value for an attribute. This replaces any value it may, or may not, have.
$entry->set('description', 'Employee');

# Send the built up changes back to LDAP to update the entry via the LDAP client update method.
try {
    $ldap->update($entry);
} catch (OperationException $e) {
    echo sprintf('Error modifying entry (%s): %s', $e->getCode(), $e->getMessage()).PHP_EOL;;
}
```

Delete
------

[](#delete)

```
use FreeDSx\Ldap\Exception\OperationException;

# Search for the entry object to delete
$entry = $ldap->read('cn=foo,dc=domain,dc=local');

# Pass the entry object to the delete method of the LDAP client if it was found.
# You could also pass a DN object or a simple DN as a string.
if ($entry) {
    try {
        $ldap->delete($entry);
    } catch (OperationException $e) {
        echo sprintf('Error deleting entry (%s): %s', $e->getCode(), $e->getMessage()).PHP_EOL;;
    }
}
```

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance58

Moderate activity, may be stable

Popularity49

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~341 days

Recently: every ~572 days

Total

10

Last Release

58d ago

Major Versions

0.8.0 → 1.0.x-dev2026-03-22

PHP version history (2 changes)0.1.0PHP &gt;=7.1

1.0.x-devPHP &gt;=8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/388229?v=4)[Chad Sikorra](/maintainers/ChadSikorra)[@ChadSikorra](https://github.com/ChadSikorra)

---

Top Contributors

[![ChadSikorra](https://avatars.githubusercontent.com/u/388229?v=4)](https://github.com/ChadSikorra "ChadSikorra (298 commits)")[![HenkPoley](https://avatars.githubusercontent.com/u/2931213?v=4)](https://github.com/HenkPoley "HenkPoley (4 commits)")[![jstormes](https://avatars.githubusercontent.com/u/2112702?v=4)](https://github.com/jstormes "jstormes (1 commits)")

---

Tags

activedirectoryldapldap-clientldap-serveropenldapphpldapopenldapactivedirectory

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/freedsx-ldap/health.svg)

```
[![Health](https://phpackages.com/badges/freedsx-ldap/health.svg)](https://phpackages.com/packages/freedsx-ldap)
```

###  Alternatives

[ldaptools/ldaptools

LdapTools is a feature-rich LDAP library for PHP 5.6+.

204263.9k1](/packages/ldaptools-ldaptools)[symfony/ldap

Provides a LDAP client for PHP on top of PHP's ldap extension

1407.5M46](/packages/symfony-ldap)[avadaneidanut/ldapquery

A light weight package for easily building LDAP advanced filter queries.

4717.8k](/packages/avadaneidanut-ldapquery)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
