PHPackages                             faulkj/ldapclient - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. faulkj/ldapclient

ActiveLibrary[HTTP &amp; Networking](/categories/http)

faulkj/ldapclient
=================

A PHP class that simplifies connecting to and searching LDAP directories.

v1.5.5(2y ago)0685UnlicensePHPPHP &gt;=7.0

Since Aug 29Pushed 2y ago1 watchersCompare

[ Source](https://github.com/faulkj/LDAPClient)[ Packagist](https://packagist.org/packages/faulkj/ldapclient)[ Docs](https://github.com/faulkj/LDAPClient/:readme)[ RSS](/packages/faulkj-ldapclient/feed)WikiDiscussions main Synced 5d ago

READMEChangelog (8)Dependencies (1)Versions (9)Used By (0)

LDAPClient
==========

[](#ldapclient)

LDAPClient is a PHP library designed to make LDAP operations easy and flexible. From basic queries to advanced LDAP functionalities, this library offers a wide range of features.

Features
--------

[](#features)

- Simplified LDAP Connection
- User Authentication
- Advanced Search Queries
- Debugging Support

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

[](#installation)

```
composer require faulkj/ldapclient
```

Methods &amp; Usage
-------------------

[](#methods--usage)

### LDAPClient Class

[](#ldapclient-class)

#### `__construct($server, $bindDN, $pass, $baseDN, $options)`

[](#__constructserver-binddn-pass-basedn-options)

Initiate a connection to the LDAP server.

- `$server`: The LDAP server URL
- `$bindDN`: The DN to bind with
- `$pass`: The password for binding
- `$baseDN`: The base DN for the directory
- `$options`: List of LDAP fields to pull. Allows for custom attribute mappings to align with the specific LDAP system you're working with.

**Example:**

```
use FaulkJ\LDAPClient

$ldap = new LDAPClient(
   "ldap.forumsys.com",
   "cn=read-only-admin,dc=example,dc=com",
   "password",
   "dc=example,dc=com",
   [
      "id" => "uid"
   ]
);
```

#### `debug($dbg)`

[](#debugdbg)

Toggle debugging output for LDAP operations. When enabled, this provides verbose output for troubleshooting.

- `$dbg`: Boolean to enable or disable debugging

**Example:**

```
$ldap->debug(true);
```

Returns:

- Current debug state if no parameter is provided
- The LDAPClient object itself, allowing for method chaining, if a parameter is provided

#### `getJSON($filter, $attr = [], $dn = false, $fullDNs = false)`

[](#getjsonfilter-attr---dn--false-fulldns--false)

Converts the search result to a JSON format.

- `$filter`: LDAP filter
- `$attr`: Attributes to fetch
- `$dn`: Optional DN to search under
- `$resolveDNs`: Whether to resolve DNs
- `$stayBound`: Whether to stay bound

**Example:**

```
die($ldap->getJSON("(ou=chemist*)", ["cn", "members" => "uniquemember"], null, true));
```

Returns: JSON-formatted string representing the search results.

#### `login($id, $pass, $attr)`

[](#loginid-pass-attr)

Authenticate a user and return their attributes.

- `$id`: User ID
- `$pass`: Password
- `$attr`: Attributes to fetch

**Example:**

```
if($user = $ldap->login("riemann", "password", ["fullname" => "cn", "mail"])) {
   echo "{$user->fullname} successfully logged in!";
}
else echo "Invalid username or password!";
```

Returns:

- User object with specified attributes if successful
- `false` if authentication fails
- `null` if the user is not found

#### `member($user, $group, $options = [])`

[](#memberuser-group-options--)

Check if a user is a member of a specific LDAP group or groups.

- `$user`: The user ID to check
- `$group`: Group or array of groups to check membership
- `$options`: Optional array for additional attribute mappings (merges with default options)

Example:

```
if($ldap->member("mathematicians", "gauss", [
   "id"     => "ou",
   "member" => "uniquemember"
])) {
   echo "gauss is a mathematician!";
}
```

Returns:

- `true` if the user is a member
- `false` if the user is not a member
- `null` if the user is not found

#### `photo($user)`

[](#photouser)

Retrieves the photo for a specified user.

**Example:**

```
$ldap->photo("simmons");
```

Returns: Outputs the image directly to the screen if available, a blank image if not

#### `search($filter, $attr, $dn, $resolveDNs, $stayBound)`

[](#searchfilter-attr-dn-resolvedns-staybound)

Perform an LDAP search.

- `$filter`: LDAP filter
- `$attr`: Attributes to fetch
- `$dn`: Optional DN to search under
- `$resolveDNs`: Whether to resolve DNs
- `$stayBound`: Whether to stay bound

**Example:**

```
$res = $ldap->search(
   "(ou=chemist*)",
   [
      "cn",
      "members" => "uniquemember"
   ],
   null,
   true
);
echo implode("\n", $res->members);
```

Returns:

- Array of LDAP records if multiple records are found
- Single LDAP record if only one is found
- null if no records are found

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

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 ~123 days

Recently: every ~109 days

Total

8

Last Release

855d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3419720?v=4)[Joshua H. Faulkenberry](/maintainers/faulkj)[@faulkj](https://github.com/faulkj)

---

Top Contributors

[![faulkj](https://avatars.githubusercontent.com/u/3419720?v=4)](https://github.com/faulkj "faulkj (24 commits)")

---

Tags

clientcurlweb servicefetch

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/faulkj-ldapclient/health.svg)

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

###  Alternatives

[eightpoints/guzzle-bundle

Integrates Guzzle 6.x, a PHP HTTP Client, into Symfony. Comes with easy and powerful configuration options and optional plugins.

45912.1M55](/packages/eightpoints-guzzle-bundle)[ismaeltoe/osms

PHP library wrapper of the Orange SMS API.

4540.0k](/packages/ismaeltoe-osms)[zoonman/pixabay-php-api

PixabayClient is a PHP HTTP client library to access Pixabay's API

3354.7k](/packages/zoonman-pixabay-php-api)[jshensh/php-curl-class

PHP HTTP client, based on cURL

532.8k](/packages/jshensh-php-curl-class)

PHPackages © 2026

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