2017 © Pedro PelĂĄez
 

library ldap

PHP library which handle LDAP data. Can parse too LDIF file.

image

smalot/ldap

PHP library which handle LDAP data. Can parse too LDIF file.

  • Monday, July 25, 2016
  • by smalot
  • Repository
  • 2 Watchers
  • 7 Stars
  • 477 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 2 Open issues
  • 6 Versions
  • 10 % Grown

The README.md

LDAP

PHP library which handle LDAP data. Can parse too LDIF file., (*1)

Prerequisites

You need at least PHP 5.3.3 and LDAP php module enabled., (*2)

Installation

Download project using composer

Add LDAP in your composer.json:, (*3)

{
    "require": {
        "smalot/ldap": "*"
    }
}

Now tell composer to download the bundle by running the command:, (*4)

``` bash $ php composer.phar update smalot/ldap, (*5)


Composer will install the bundle to your project's `smalot/ldap` directory. ## Documentation ### Connect to LDAP server (simple) ``` php <?php require 'vendor/autoload.php'; $server = new \Smalot\Ldap\Server(); $server->bind('cn=admin,dc=nodomain', 'S3CR3T');

Connect to LDAP server (with options)

``` php <?php, (*6)

require 'vendor/autoload.php';, (*7)

$options = array( LDAP_OPT_PROTOCOL_VERSION => 3, );, (*8)

$server = new \Smalot\Ldap\Server('127.0.0.1', 389, $options); $server->bind('cn=admin,dc=nodomain', 'S3CR3T');, (*9)


### Find objects ``` php <?php require 'vendor/autoload.php'; $server = new \Smalot\Ldap\Server(); $server->bind('cn=admin,dc=nodomain', 'S3CR3T'); $repository = $server->getDefaultRepository(); $results = $repository->search('ou=Users,dc=nodomain', '(objectClass=*)'); while ($result = $results->fetchEntry()) { // Handle result object acording to your needs }

Find object using its distinguished named

``` php <?php, (*10)

require 'vendor/autoload.php';, (*11)

$server = new \Smalot\Ldap\Server(); $server->bind('cn=admin,dc=nodomain', 'S3CR3T');, (*12)

$repository = $server->getDefaultRepository();, (*13)

// Returns null if nothing found $object = $repository->searchDN('uid=User1,ou=Users,dc=nodomain');, (*14)


### Create object (and add it) ``` php <?php require 'vendor/autoload.php'; $server = new \Smalot\Ldap\Server(); $server->bind('cn=admin,dc=nodomain', 'S3CR3T'); $repository = $server->getDefaultRepository(); // Create a new user $dn = 'uid=User1,ou=Users,dc=nodomain'; $user = new \Smalot\Ldap\Object($dn); $user->get('objectClass')->add('top'); $user->get('objectClass')->add('inetOrgPerson'); $user->get('objectClass')->add('posixAccount'); $user->get('displayName')->setValue('Username'); $user->get('mail')->set('username@example.org'); $user->get('cn')->set('Username'); $user->get('sn')->set('Username'); $user->get('givenName')->set('Username'); $user->get('displayName')->set('Username'); $user->get('gidNumber')->set(0); $user->get('uidNumber')->set(1001); $user->get('homeDirectory')->set('/home/false'); $user->get('loginShell')->set('/sbin/nologin'); $password = \Smalot\Ldap\Tools::generateRandomPassword(); $user->get('userPassword')->set(\Smalot\Ldap\Tools::encodePassword($password)); // ... // Store the new user $repository->add($user); // Create a new group $dn = 'cn=Group1,ou=Groups,dc=nodomain'; $group = new \Smalot\Ldap\Object($dn); $group->get('objectClass')->add('top'); $group->get('objectClass')->add('posixGroup'); $group->get('gidNumber')->set(2001); // Store the new group $repository->add($group); // Link user to the group $repository->modify($group, 'add', array('memberUid' => $user->get('uid')->getValue()));

The Versions

25/07 2016

dev-master

9999999-dev

PHP library which handle LDAP data. Can parse too LDIF file.

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

ldap openldap ldif

25/07 2016

v0.4

0.4.0.0

PHP library which handle LDAP data. Can parse too LDIF file.

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

ldap openldap ldif

16/05 2016

v0.3

0.3.0.0

PHP library which handle LDAP data. Can parse too LDIF file.

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

ldap openldap ldif

15/02 2016

v0.2.1

0.2.1.0

PHP library which handle LDAP data. Can parse too LDIF file.

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

ldap openldap ldif

15/02 2016

v0.2.0

0.2.0.0

PHP library which handle LDAP data. Can parse too LDIF file.

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

ldap openldap ldif

07/04 2014

v0.1.0

0.1.0.0

PHP library which handle LDAP data. Can parse too LDIF file.

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

ldap openldap ldif