Usage Scenarios
Basic CRUD operations
Retrieving data from the LDAP
Example #1 Getting an entry by its DN
span style="color: #808080; font-style: italic;">/* ... */'cn=Hugo Müller,ou=People,dc=my,dc=local');
/*
$hm is an array of the following structure
array(
'dn' => 'cn=Hugo Müller,ou=People,dc=my,dc=local',
'cn' => array('Hugo Müller'),
'sn' => array('Müller'),
'objectclass' => array('inetOrgPerson', 'top'),
...
)
*/
Example #2 Check for the existence of a given DN
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
span style="color: #808080; font-style: italic;">/* ... */'cn=Hugo Müller,ou=People,dc=my,dc=local');
Example #4 Searching the LDAP tree
span style="color: #808080; font-style: italic;">/* ... */'(objectclass=*)',
'ou=People,dc=my,dc=local'"dn"] . ': ' . $item['cn'
Adding data to the LDAP
Example #5 Add a new entry to the LDAP
span style="color: #808080; font-style: italic;">/* ... */'cn', 'Hans Meier''sn', 'Meier''objectClass', 'inetOrgPerson');
$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
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
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
span style="color: #808080; font-style: italic;">/* ... */'cn=Hugo Müller,ou=People,dc=my,dc=local',
'cn=Hans Meier,ou=People,dc=my,dc=local'
Example #9
Move a LDAP entry recursively with all its descendants to a different subtree
span style="color: #808080; font-style: italic;">/* ... */'cn=Hugo Müller,ou=People,dc=my,dc=local',
'ou=Dismissed,dc=my,dc=local'
|
|