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

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

jstormes/ldap
=============

ldap connector

0.0.3(7y ago)020GPL-3.0-or-laterPHPPHP ^7.0

Since Oct 11Pushed 4y ago1 watchersCompare

[ Source](https://github.com/jstormes/ldap)[ Packagist](https://packagist.org/packages/jstormes/ldap)[ RSS](/packages/jstormes-ldap/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (3)Versions (6)Used By (0)

LdapConnector
=============

[](#ldapconnector)

LDAP Connector – A quick way to login and get user details from a LDAP AD or Open LDAP server.

As part of creating a Single Sign On (SSO) solution to Open LDAP and Active Directory (AD) I needed to validate users against their LDAP User Name and Password. I also wanted to pull some basic user information like their display name, Email address and Group Membership.

This composer package provides that very limited LDAP functionality, implemented with a consistent interface across both AD and Open LDAP.

This package also forces TLS only connections to the LDAP server. The public certificate for the LDAP server **MUST**be available to the PHP server's chain of trust.

TODO:
=====

[](#todo)

add password change:

Found hint as to how at

CLI Testing Quick Start
-----------------------

[](#cli-testing-quick-start)

Make sure you have Docker and Docker Compose installed.

- `docker-compose run composer install`
- `docker-compose run phpunit`

PHPStorm Testing Quick Start
----------------------------

[](#phpstorm-testing-quick-start)

- File-&gt;Settings-&gt;PHP-&gt;CLI Interpreter-&gt;...

    - + From Docker ...
        - Docker Compose
        - Server: Docker
        - Configuration file(s): .\\docker-compose.yml
        - Service: phpunit
- File-&gt;Settings-&gt;Languages &amp; Frameworks-&gt;PHP-&gt;Test Frameworks

    - + PHPUnit by Remote Interpreter
        - CLI Interpreter: ldap\_test:latest
        - PHPUnit library \* Use Composer autoloader
        - Path to script: /opt/project/vendor/autoload.php
        - Default configuration file: /opt/project/phpunit.xml.dist
- Run-&gt;Edit Configurations

    - + PHPUnit
        - Name Docker PHPUnit
        - Defined in configuration file

Usage Example
-------------

[](#usage-example)

```
use JStormes\Ldap\Connector\Connector;
use JStormes\Ldap\LdapAdapter\LdapAdapter;
use JStormes\Ldap\SchemaAdapter\SchemaAdapterOpenLDAP as SchemaAdapter;
use Psr\Log\NullLogger;

$serverString = "LOOPBACK:us.loopback.world:DC=us,DC=loopback,DC=world";

$ldapAdapter = new LdapAdapter();
$schemaAdapter = new SchemaAdapter($serverString);
$logger = new NullLogger();

$connector = new Connector($ldapAdapter, $schemaAdapter, $logger);
$username = 'testUser';
$password = 'test';
$isConnected = $connector->connect($username, $password);
$user = $connector->getUserEntity();

$userName = $user->getUserName();
$dispalyName = $user->getDisplayName();
$email = $user->getEmailAddress();
$groups = $user->getUserGroups();
```

Interactive Testing
-------------------

[](#interactive-testing)

The interactive testing code is in `bin\test_ldap.php`.

- `docker-compose run composer install`
- `docker-compose run bash`
    - `test_ldap.php`
    - LDAP Username: `testUser`
    - Password: `test`

To test with your own LDAP setup change the line `LDAP_SERVER: LOOPBACK:us.loopback.world:DC=us,DC=loopback,DC=world:OpenLDAP` in the file `docker-compose.yml` to point to your own server and restart the docker-compose command.

This Interactive Testing session uses XDebug, change the XDebug line to match your setup.

Mock LdapAdapters
-----------------

[](#mock-ldapadapters)

The LdapAdapter is mostly a wrapper for code that is difficult to unit test. To make TDD simpler, I created mock versions of this hard to unit test code.

Two versions of the LdapAdapter were created. The first, `LdapAdMockAdapter.php` is for mocking a connection to a Microsoft Active Directory LDAP server. The accepted bind and the returned search results simulate a connection to Microsoft AD over LDAP.

The second mock `LdapOpenLdapMockAdatper.php`, simulates a connection to a Open LDAP server.

Using both mocks it was possible to do TDD using these mocks as stand ins for the real LDAP servers.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

3

Last Release

2770d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a9e7d7df68115ec07df0caef4ea1918d83eaef78cf85404183420c02dc4aeba6?d=identicon)[jstormes](/maintainers/jstormes)

---

Top Contributors

[![jstormes](https://avatars.githubusercontent.com/u/2112702?v=4)](https://github.com/jstormes "jstormes (35 commits)")

---

Tags

activedirectoryldapphpAuthenticationSSOidentityauthorizationidpsingle sign onldapad

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[league/oauth2-client

OAuth 2.0 Client Library

3.8k118.6M1.2k](/packages/league-oauth2-client)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[adam-paterson/oauth2-stripe

Stripe OAuth 2.0 Client Provider for The PHP League OAuth2-Client

172.4M4](/packages/adam-paterson-oauth2-stripe)[adam-paterson/oauth2-slack

Slack OAuth 2.0 Client Provider for The PHP League OAuth2-Client

22694.8k5](/packages/adam-paterson-oauth2-slack)

PHPackages © 2026

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