API overview

Usage Scenarios

Authentication scenarios

OpenLDAP

ActiveDirectory

Basic CRUD operations

Retrieving data from the LDAP

Example #1 Getting an entry by its DN

  1. span style="color: #808080; font-style: italic;">/* ... */'cn=Hugo Müller,ou=People,dc=my,dc=local');
  2. /*
  3. $hm is an array of the following structure
  4. array(
  5.     'dn'          => 'cn=Hugo Müller,ou=People,dc=my,dc=local',
  6.     'cn'          => array('Hugo Müller'),
  7.     'sn'          => array('Müller'),
  8.     'objectclass' => array('inetOrgPerson', 'top'),
  9.     ...
  10. )
  11. */

Example #2 Check for the existence of a given DN

  1. span style="color: #808080; font-style: italic;">/* ... */'cn=Hugo Müller,ou=People,dc=my,dc=local');

Example #3 Count children of a given DN

  1. span style="color: #808080; font-style: italic;">/* ... */'cn=Hugo Müller,ou=People,dc=my,dc=local');

Example #4 Searching the LDAP tree

  1. span style="color: #808080; font-style: italic;">/* ... */'(objectclass=*)',
  2.                         'ou=People,dc=my,dc=local'"dn"] . ': ' . $item['cn'

Adding data to the LDAP

Example #5 Add a new entry to the LDAP

  1. span style="color: #808080; font-style: italic;">/* ... */'cn', 'Hans Meier''sn', 'Meier''objectClass', 'inetOrgPerson');
  2. $ldap->add('cn=Hans Meier,ou=People,dc=my,dc=local', $entry);

Deleting from the LDAP

Example #6 Delete an existing entry from the LDAP

  1. span style="color: #808080; font-style: italic;">/* ... */'cn=Hans Meier,ou=People,dc=my,dc=local');

Updating the LDAP

Example #7 Update an existing entry on the LDAP

  1. span style="color: #808080; font-style: italic;">/* ... */'cn=Hugo Müller,ou=People,dc=my,dc=local''mail', '[email protected]''newPa$$w0rd''cn=Hugo Müller,ou=People,dc=my,dc=local', $hm);

Extended operations

Copy and move entries in the LDAP

Example #8 Copy a LDAP entry recursively with all its descendants

  1. span style="color: #808080; font-style: italic;">/* ... */'cn=Hugo Müller,ou=People,dc=my,dc=local',
  2.             'cn=Hans Meier,ou=People,dc=my,dc=local'

Example #9 Move a LDAP entry recursively with all its descendants to a different subtree

  1. span style="color: #808080; font-style: italic;">/* ... */'cn=Hugo Müller,ou=People,dc=my,dc=local',
  2.                      'ou=Dismissed,dc=my,dc=local'

API overview