PHPackages                             comodojo/ldaph - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. comodojo/ldaph

AbandonedArchivedLibrary[Authentication &amp; Authorization](/categories/authentication)

comodojo/ldaph
==============

poor man's php ldap class

1.0.3(7y ago)11.8k2MITPHPPHP &gt;=5.3.0CI failing

Since May 7Pushed 4y ago4 watchersCompare

[ Source](https://github.com/comodojo/ldaph)[ Packagist](https://packagist.org/packages/comodojo/ldaph)[ Docs](https://comodojo.org)[ RSS](/packages/comodojo-ldaph/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (4)Dependencies (3)Versions (6)Used By (0)

comodojo.ldaph
==============

[](#comodojoldaph)

[![Build Status](https://camo.githubusercontent.com/90b05bbd199d12e79081ade208f8b36c016755690a9d1f60311e041a844ca627/68747470733a2f2f6170692e7472617669732d63692e6f72672f636f6d6f646f6a6f2f6c646170682e706e67)](http://travis-ci.org/comodojo/ldaph) [![Latest Stable Version](https://camo.githubusercontent.com/dfcaa263503e4dfe24c5312c2eb3115650db873bfc8d4f87e910d865aee0d81e/68747470733a2f2f706f7365722e707567782e6f72672f636f6d6f646f6a6f2f6c646170682f762f737461626c65)](https://packagist.org/packages/comodojo/ldaph) [![Total Downloads](https://camo.githubusercontent.com/6fe69d11d9f94ed05b7d2cdeb23db7e7313e6889c350ec89df5c8d5d3aedf9c0/68747470733a2f2f706f7365722e707567782e6f72672f636f6d6f646f6a6f2f6c646170682f646f776e6c6f616473)](https://packagist.org/packages/comodojo/ldaph) [![Latest Unstable Version](https://camo.githubusercontent.com/2d42383c92d855f8f8f343ece3cf231d158e9c32b5e850a47856167fa8bd9b68/68747470733a2f2f706f7365722e707567782e6f72672f636f6d6f646f6a6f2f6c646170682f762f756e737461626c65)](https://packagist.org/packages/comodojo/ldaph) [![License](https://camo.githubusercontent.com/6cb1e05a6910e53dac04690dd3e9aff50df94905dc94a9aa657e8cde656127e4/68747470733a2f2f706f7365722e707567782e6f72672f636f6d6f646f6a6f2f6c646170682f6c6963656e7365)](https://packagist.org/packages/comodojo/ldaph) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/ef7c3495d6b6f37aa80585e49439116d192a10c3ea1027f8e26f0b28b106ee42/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f636f6d6f646f6a6f2f6c646170682f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/comodojo/ldaph/?branch=master) [![Code Coverage](https://camo.githubusercontent.com/e14fd05391e6cc9c07971f00941af06171d4151c393e6dcc6f482eca3b4ff1fe/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f636f6d6f646f6a6f2f6c646170682f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/comodojo/ldaph/?branch=master)

poor man's php ldap class

Ldaph is a simple library made to handle LDAP/ActiveDirectory authentication and search.

It supports:

- ssl (ldaps)
- tls
- single sign on (Active Directory)

Installation
------------

[](#installation)

Install [composer](https://getcomposer.org/), then:

`composer require comodojo/ldaph 1.0.*`

Basic Usage
-----------

[](#basic-usage)

- Creating an instance

    Class constructor expects ldap server and port as parameters. Wrap it in a try/catch block, since it may generate a `LdaphException` in case of wrong parameters or missed php ext.

    ```
    try {

    	$ldap = new \Comodojo\Ldaph('ldap.exampe.com', 389);

    }
    catch (LdaphException $le){

    	// handle exception here

    }
    ```
- User authentication

    ```
    $dn = "uid=john,dc=example,dc=com";

    try {

    	$ldap = new \Comodojo\Ldaph('ldap.exampe.com', 389);
    	$lauth = $ldap->dn($dn)->auth('john', 'doe');

    }
    catch (LdaphException $le){

    	// handle exception here

    }
    ```

    Defining DN, there is a special word USERNAME that will be replaced with first auth() parameter ($username).

    Examples of DN:

    - "" (for Active Directory)
    - "uid=USERNAME,dc=example,dc=com" (for openLDAP)
- Search LDAP tree

    Searching into ldap tree requires, at least:

    - base DN (base)
    - search DN (searchbase)
    - bind DN (dn)
    - account (user/pass)

    `search()` method will list ldap tree using this parameters.

    ```
    $dn = "uid=USERNAME,dc=example,dc=com";
    $base = "dc=example,dc=com";
    $searchbase = "(uid=PATTERN)";

    try {

    	$ldap = new \Comodojo\Ldaph('ldap.exampe.com', 389);

    	$lsearch = $ldap->base($base)
    					->searchbase($searchbase)
    					->dn($dn)
    					->account('john', 'doe')
    					->search("*",true);

    }
    catch (LdaphException $le){

    	// handle exception here

    }
    ```

    Special word 'PATTERN' in searchbase will be replaced with first `search()` parameter.

    Second parameter (if true) will return results in a more convenient, array-based form.

    Examples of searchbase (if you are looking for usernames):

    - "(&amp;(!(objectClass=computer))(|(anr=PATTERN)))" (for Active Directory)
    - "(uid=PATTERN)" (for openLDAP)

Documentation
-------------

[](#documentation)

- [API](https://api.comodojo.org/libs/Comodojo/Ldaph.html)

Contributing
------------

[](#contributing)

Contributions are welcome and will be fully credited. Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

License
-------

[](#license)

`comodojo/ldaph` is released under the MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 90% 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 ~327 days

Total

5

Last Release

2717d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.1.3

1.0.2PHP &gt;=5.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4cc933c2d1b92f7fd32abb459387bff69fc8a87158b1474171ccf26139904706?d=identicon)[comodojo](/maintainers/comodojo)

---

Top Contributors

[![marcogiovinazzi](https://avatars.githubusercontent.com/u/12754673?v=4)](https://github.com/marcogiovinazzi "marcogiovinazzi (9 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

---

Tags

phpAuthenticationSSOldapactive directorydirectory searchldaps

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/comodojo-ldaph/health.svg)

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

###  Alternatives

[causal/ig_ldap_sso_auth

This extension provides LDAP support for TYPO3 by delegating the authentication of frontend and/or backend users to the centrally-managed directory of your organization. It fully supports OpenLDAP and Active Directory and is capable of connecting securely to the authentication server using either TLS or SSL (ldaps://). In case of use in an intranet environment, this extension is a perfect match since it natively brings Single Sign-On (SSO) capability to TYPO3 without any complex configuration.

33377.4k](/packages/causal-ig-ldap-sso-auth)[maicol07/flarum-ext-sso

SSO for Flarum

468.3k](/packages/maicol07-flarum-ext-sso)

PHPackages © 2026

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