PHPackages                             macameaum/ldap\_orm - 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. [Database &amp; ORM](/categories/database)
4. /
5. macameaum/ldap\_orm

ActiveLibrary[Database &amp; ORM](/categories/database)

macameaum/ldap\_orm
===================

06PHP

Since Feb 15Pushed 7y ago1 watchersCompare

[ Source](https://github.com/makamo/LDAP_ORM)[ Packagist](https://packagist.org/packages/macameaum/ldap_orm)[ RSS](/packages/macameaum-ldap-orm/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP LDAP ORM
============

[](#php-ldap-orm)

About
-----

[](#about)

LDAP ORM is a simple PHP Library that makes searching for records in LDAP and saving or updating easier. It is inspired by CakePHP/Rails and supports both 'hasMany' and 'belongsTo' associations. It also supports 'findBy{Attribute}' and 'findAllBy{Attribute}' functions for quick retrieval of records.

Feature List
------------

[](#feature-list)

- SASL Support (if proper LDAP PHP Libraries are Installed)
- findBy and findAllBy magic methods
- Single DN Result
- Save and Update with strict mode (check that attributes exist in schema before updating)
- 'hasMany' and 'belongsTo' support
- 'Find' supports: all, first, count, list
- Find conditions can use AND or OR between values ie. "cn=Test OR cn=Test2" and proper LDAP search formatting will be applied.
    - Note: Only one method can be used at a time but multiple of the same methods can be used "cn=Test AND cn=Test2 AND name=Test"
- Organizes results by the top most dn value
    - Example: results under a dn of ou=People,dc=example,dc=com would be namespaced in results under '\[People\]' array

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

[](#basic-usage)

Find All Records with cn=TestGroup

```
require('LDAP_ORM.php');

$ldap = new LDAP_ORM('example.com');
$ldap->bind('cn=admin,dc=example,dc=com', 'password');

$res = $ldap->find('all', array('conditions' => "cn=testGroup"), 'ou=Groups,dc=example,dc=com');
```

Alternatively the above query can be written using the findAllBy magic method:

```
require('LDAP_ORM.php');

$ldap = new LDAP_ORM('example.com');
$ldap->bind('cn=admin,dc=example,dc=com', 'password');

$res = $ldap->findAllByCn("testGroup", 'ou=Groups,dc=example,dc=com');
```

The results above both examples will return as

```
(
   [0] => Array
        (
            [Groups] => Array
                (
                    [cn] => testGroup
                    [objectclass] => Array
                        (
                            [0] => groupOfNames
                            [1] => top
                        )
                    [member] => Array
                        (
                            [0] => cn=TestUser,ou=People,dc=example,dc=com
                            [1] => cn=Test3,ou=People,dc=example,dc=com
                        )
                    [dn] => cn=testGroup,ou=Groups,dc=example,dc=com
                )
            )
        )
   )
```

Advanced Usage
--------------

[](#advanced-usage)

To search using the hasMany association such as finding a Group where cn=testGroup and find all the People that are listed in the members multi-attribute use the following format:

```
require('LDAP_ORM.php');

$ldap = new LDAP_ORM('example.com');
$ldap->bind('cn=admin,dc=example,dc=com', 'password');

$res = $ldap->find('first', array('conditions' => "cn=testGroup"
	'hasMany' => array(
        'on' => array('member' => 'dn'),
        'fields' => array(),
        'base' => 'ou=People,dc=example,dc=com')
    ), 'ou=Groups,dc=example,dc=com');
```

the 'on' array uses the format array('{FoundResultAttribute}' =&gt; '{AttributeToSearchForInJoinedResults}')

the Result of this would look like:

```
Array
(
    [0] => Array
        (
            [Groups] => Array
                (
                    [cn] => testGroup
                    [objectclass] => Array
                        (
                            [0] => groupOfNames
                            [1] => top
                        )
                    [member] => Array
                        (
                            [0] => cn=TestUser,ou=People,dc=example,dc=com
                            [1] => cn=Test3,ou=People,dc=example,dc=com
                        )
                    [dn] => cn=testGroup,ou=Groups,dc=example,dc=com
                )
            [People] => Array
                (
                    [0] => Array
                        (
                            [sn] => Test
                            [cn] => TestUser
                            [objectclass] => Array
                                (
                                    [0] => person
                                    [1] => top
                                )
                            [dn] => cn=TestUser,ou=People,dc=example,dc=com
                        )
                    [1] => Array
                        (
                            [cn] => Test3
                            [objectclass] => Array
                                (
                                    [0] => person
                                    [1] => top
                                )
                            [sn] => dsfsdfsd
                            [dn] => cn=Test3,ou=People,dc=example,dc=com
                        )
                )
        )
)
```

to use the BelongsTo option:

```
require('LDAP_ORM.php');

$ldap = new LDAP_ORM('example.com');
$ldap->bind('cn=admin,dc=example,dc=com', 'password');

$g = $ldap->find('all', array('conditions' => "cn=Test2",
    'belongsTo' => array(
        'on' => array('groupdn' => 'dn'),
        'base' => 'ou=Groups,dc=example,dc=com')
), 'ou=People,dc=example,dc=com');
```

More Examples
-------------

[](#more-examples)

See [Examples.md](Examples)

License
-------

[](#license)

LDAP ORM is Licensed under the Creative Commons Attribution 3.0 license

Issues
------

[](#issues)

Please use GitHub Issues to submit any problems found

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/414d4916dc156408c6b89c4015a741402e1a03f6a0213deb7cd687c1de514bbf?d=identicon)[makamo](/maintainers/makamo)

---

Top Contributors

[![ibspoof](https://avatars.githubusercontent.com/u/958?v=4)](https://github.com/ibspoof "ibspoof (3 commits)")

### Embed Badge

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

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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