Exemple 492. Récupérer une entrée grâce à son DN
$options = array(/* ... */); $ldap = new Zend_Ldap($options); $ldap->bind(); $hm = $ldap->getEntry('cn=Hugo Müller,ou=People,dc=my,dc=local'); /* $hm est un tableau à la structure suivante: 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'), ... ) */
Exemple 493. Vérifier l'existence d'un DN donné
$options = array(/* ... */); $ldap = new Zend_Ldap($options); $ldap->bind(); $isThere = $ldap->exists('cn=Hugo Müller,ou=People,dc=my,dc=local');
Exemple 494. Compter les enfants d'un DN donné
$options = array(/* ... */); $ldap = new Zend_Ldap($options); $ldap->bind(); $childrenCount = $ldap->countChildren( 'cn=Hugo Müller,ou=People,dc=my,dc=local');
Exemple 495. Chercher dans l'arbre LDAP
$options = array(/* ... */); $ldap = new Zend_Ldap($options); $ldap->bind(); $result = $ldap->search('(objectclass=*)', 'ou=People,dc=my,dc=local', Zend_Ldap_Ext::SEARCH_SCOPE_ONE); foreach ($result as $item) { echo $item["dn"] . ': ' . $item['cn'][0] . PHP_EOL; }
Exemple 496. Ajouter une nouvelle entrée à LDAP
$options = array(/* ... */); $ldap = new Zend_Ldap($options); $ldap->bind(); $entry = array(); Zend_Ldap_Attribute::setAttribute($entry, 'cn', 'Hans Meier'); Zend_Ldap_Attribute::setAttribute($entry, 'sn', 'Meier'); Zend_Ldap_Attribute::setAttribute($entry, 'objectClass', 'inetOrgPerson'); $ldap->add('cn=Hans Meier,ou=People,dc=my,dc=local', $entry);
Exemple 497. Supprimer une entrée existante de LDAP
$options = array(/* ... */); $ldap = new Zend_Ldap($options); $ldap->bind(); $ldap->delete('cn=Hans Meier,ou=People,dc=my,dc=local');
Exemple 498. Mettre à jour une entrée existante dans LDAP
$options = array(/* ... */); $ldap = new Zend_Ldap($options); $ldap->bind(); $hm = $ldap->getEntry('cn=Hugo Müller,ou=People,dc=my,dc=local'); Zend_Ldap_Attribute::setAttribute($hm, 'mail', 'mueller@my.local'); Zend_Ldap_Attribute::setPassword($hm, 'newPa$$w0rd', Zend_Ldap_Attribute::PASSWORD_HASH_SHA1); $ldap->update('cn=Hugo Müller,ou=People,dc=my,dc=local', $hm);
Exemple 499. Copier une entrée LDAP récursivement avec tous ses descendants
$options = array(/* ... */); $ldap = new Zend_Ldap($options); $ldap->bind(); $ldap->copy('cn=Hugo Müller,ou=People,dc=my,dc=local', 'cn=Hans Meier,ou=People,dc=my,dc=local', true);
Exemple 500. Déplacer une entrée LDAP récursivement vers un sous-arbre différent
$options = array(/* ... */); $ldap = new Zend_Ldap($options); $ldap->bind(); $ldap->moveToSubtree('cn=Hugo Müller,ou=People,dc=my,dc=local', 'ou=Dismissed,dc=my,dc=local', true);