|
|
@@ -0,0 +1,178 @@
|
|
|
+<?xml version="1.0" encoding="UTF-8"?>
|
|
|
+<!-- EN-Revision: 21496 -->
|
|
|
+<!-- Reviewed: no -->
|
|
|
+<sect1 id="zend.ldap.usage">
|
|
|
+ <title>Scénarios d'utilisation</title>
|
|
|
+
|
|
|
+ <sect2 id="zend.ldap.usage.authentication">
|
|
|
+ <title>Scénarios d'authentification</title>
|
|
|
+
|
|
|
+ <sect3 id="zend.ldap.usage.authentication.openldap">
|
|
|
+ <title>OpenLDAP</title>
|
|
|
+ <para/>
|
|
|
+ </sect3>
|
|
|
+
|
|
|
+ <sect3 id="zend.ldap.usage.authentication.activedirectory">
|
|
|
+ <title>ActiveDirectory</title>
|
|
|
+ <para/>
|
|
|
+ </sect3>
|
|
|
+ </sect2>
|
|
|
+
|
|
|
+ <sect2 id="zend.ldap.usage.basic">
|
|
|
+ <title>Opérations CRUD basiques</title>
|
|
|
+
|
|
|
+ <sect3 id="zend.ldap.usage.basic.retrieve">
|
|
|
+ <title>Récupérer des données depuis LDAP</title>
|
|
|
+
|
|
|
+ <example id="zend.ldap.usage.basic.retrieve.dn">
|
|
|
+ <title>Récupérer une entrée grâce à son DN</title>
|
|
|
+
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
+$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'),
|
|
|
+ ...
|
|
|
+)
|
|
|
+*/
|
|
|
+]]></programlisting>
|
|
|
+ </example>
|
|
|
+
|
|
|
+ <example id="zend.ldap.usage.basic.retrieve.exists">
|
|
|
+ <title>Vérifier l'existence d'un DN donné</title>
|
|
|
+
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
+$options = array(/* ... */);
|
|
|
+$ldap = new Zend_Ldap($options);
|
|
|
+$ldap->bind();
|
|
|
+$isThere = $ldap->exists('cn=Hugo Müller,ou=People,dc=my,dc=local');
|
|
|
+]]></programlisting>
|
|
|
+ </example>
|
|
|
+
|
|
|
+ <example id="zend.ldap.usage.basic.retrieve.counting-children">
|
|
|
+ <title>Compter les enfants d'un DN donné</title>
|
|
|
+
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
+$options = array(/* ... */);
|
|
|
+$ldap = new Zend_Ldap($options);
|
|
|
+$ldap->bind();
|
|
|
+$childrenCount = $ldap->countChildren(
|
|
|
+ 'cn=Hugo Müller,ou=People,dc=my,dc=local');
|
|
|
+]]></programlisting>
|
|
|
+ </example>
|
|
|
+
|
|
|
+ <example id="zend.ldap.usage.basic.retrieve.search">
|
|
|
+ <title>Chercher dans l'arbre LDAP</title>
|
|
|
+
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
+$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;
|
|
|
+}
|
|
|
+]]></programlisting>
|
|
|
+ </example>
|
|
|
+ </sect3>
|
|
|
+
|
|
|
+ <sect3 id="zend.ldap.usage.basic.add">
|
|
|
+ <title>Ajouter des données à LDAP</title>
|
|
|
+
|
|
|
+ <example>
|
|
|
+ <title>Ajouter une nouvelle entrée à LDAP</title>
|
|
|
+
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
+$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);
|
|
|
+]]></programlisting>
|
|
|
+ </example>
|
|
|
+ </sect3>
|
|
|
+
|
|
|
+ <sect3 id="zend.ldap.usage.basic.delete">
|
|
|
+ <title>Supprimer de LDAP</title>
|
|
|
+
|
|
|
+ <example>
|
|
|
+ <title>Supprimer une entrée existante de LDAP</title>
|
|
|
+
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
+$options = array(/* ... */);
|
|
|
+$ldap = new Zend_Ldap($options);
|
|
|
+$ldap->bind();
|
|
|
+$ldap->delete('cn=Hans Meier,ou=People,dc=my,dc=local');
|
|
|
+]]></programlisting>
|
|
|
+ </example>
|
|
|
+ </sect3>
|
|
|
+
|
|
|
+ <sect3 id="zend.ldap.usage.basic.update">
|
|
|
+ <title>Mettre à jour LDAP</title>
|
|
|
+
|
|
|
+ <example>
|
|
|
+ <title>Mettre à jour une entrée existante dans LDAP</title>
|
|
|
+
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
+$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);
|
|
|
+]]></programlisting>
|
|
|
+ </example>
|
|
|
+ </sect3>
|
|
|
+ </sect2>
|
|
|
+
|
|
|
+ <sect2 id="zend.ldap.usage.extended">
|
|
|
+ <title>Opérations avancées</title>
|
|
|
+
|
|
|
+ <sect3 id="zend.ldap.usage.extended.copy-and-move">
|
|
|
+ <title>Copier et déplacer des entrées LDAP</title>
|
|
|
+
|
|
|
+ <example id="zend.ldap.usage.extended.copy-and-move.copy">
|
|
|
+ <title>Copier une entrée LDAP récursivement avec tous ses descendants</title>
|
|
|
+
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
+$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);
|
|
|
+]]></programlisting>
|
|
|
+ </example>
|
|
|
+
|
|
|
+ <example id="zend.ldap.usage.extended.copy-and-move.move-to-subtree">
|
|
|
+ <title>
|
|
|
+ Déplacer une entrée LDAP récursivement vers un sous-arbre différent
|
|
|
+ </title>
|
|
|
+
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
+$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);
|
|
|
+]]></programlisting>
|
|
|
+ </example>
|
|
|
+ </sect3>
|
|
|
+ </sect2>
|
|
|
+</sect1>
|