[ZF-10089] Zend_Log
[zend.git] / documentation / manual / fr / module_specs / Zend_Ldap-Usage.xml
blobb553ddba93c4ade54975b9e53b052f83c3130faa
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- EN-Revision: 21496 -->
3 <!-- Reviewed: no -->
4 <sect1 id="zend.ldap.usage">
5     <title>Scénarios d'utilisation</title>
7     <sect2 id="zend.ldap.usage.authentication">
8         <title>Scénarios d'authentification</title>
10         <sect3 id="zend.ldap.usage.authentication.openldap">
11             <title>OpenLDAP</title>
12             <para/>
13         </sect3>
15         <sect3 id="zend.ldap.usage.authentication.activedirectory">
16             <title>ActiveDirectory</title>
17             <para/>
18         </sect3>
19     </sect2>
21     <sect2 id="zend.ldap.usage.basic">
22         <title>Opérations CRUD basiques</title>
24         <sect3 id="zend.ldap.usage.basic.retrieve">
25             <title>Récupérer des données depuis LDAP</title>
27             <example id="zend.ldap.usage.basic.retrieve.dn">
28                 <title>Récupérer une entrée grâce à son DN</title>
30                 <programlisting language="php"><![CDATA[
31 $options = array(/* ... */);
32 $ldap = new Zend_Ldap($options);
33 $ldap->bind();
34 $hm = $ldap->getEntry('cn=Hugo Müller,ou=People,dc=my,dc=local');
36 $hm est un tableau à la structure suivante:
37 array(
38     'dn'          => 'cn=Hugo Müller,ou=People,dc=my,dc=local',
39     'cn'          => array('Hugo Müller'),
40     'sn'          => array('Müller'),
41     'objectclass' => array('inetOrgPerson', 'top'),
42     ...
45 ]]></programlisting>
46             </example>
48             <example id="zend.ldap.usage.basic.retrieve.exists">
49                 <title>Vérifier l'existence d'un DN donné</title>
51                 <programlisting language="php"><![CDATA[
52 $options = array(/* ... */);
53 $ldap = new Zend_Ldap($options);
54 $ldap->bind();
55 $isThere = $ldap->exists('cn=Hugo Müller,ou=People,dc=my,dc=local');
56 ]]></programlisting>
57             </example>
59             <example id="zend.ldap.usage.basic.retrieve.counting-children">
60                 <title>Compter les enfants d'un DN donné</title>
62                 <programlisting language="php"><![CDATA[
63 $options = array(/* ... */);
64 $ldap = new Zend_Ldap($options);
65 $ldap->bind();
66 $childrenCount = $ldap->countChildren(
67                             'cn=Hugo Müller,ou=People,dc=my,dc=local');
68 ]]></programlisting>
69             </example>
71             <example id="zend.ldap.usage.basic.retrieve.search">
72                 <title>Chercher dans l'arbre LDAP</title>
74                 <programlisting language="php"><![CDATA[
75 $options = array(/* ... */);
76 $ldap = new Zend_Ldap($options);
77 $ldap->bind();
78 $result = $ldap->search('(objectclass=*)',
79                         'ou=People,dc=my,dc=local',
80                         Zend_Ldap_Ext::SEARCH_SCOPE_ONE);
81 foreach ($result as $item) {
82     echo $item["dn"] . ': ' . $item['cn'][0] . PHP_EOL;
84 ]]></programlisting>
85             </example>
86         </sect3>
88         <sect3 id="zend.ldap.usage.basic.add">
89             <title>Ajouter des données à LDAP</title>
91             <example>
92                 <title>Ajouter une nouvelle entrée à LDAP</title>
94                 <programlisting language="php"><![CDATA[
95 $options = array(/* ... */);
96 $ldap = new Zend_Ldap($options);
97 $ldap->bind();
98 $entry = array();
99 Zend_Ldap_Attribute::setAttribute($entry, 'cn', 'Hans Meier');
100 Zend_Ldap_Attribute::setAttribute($entry, 'sn', 'Meier');
101 Zend_Ldap_Attribute::setAttribute($entry, 'objectClass', 'inetOrgPerson');
102 $ldap->add('cn=Hans Meier,ou=People,dc=my,dc=local', $entry);
103 ]]></programlisting>
104             </example>
105         </sect3>
107         <sect3 id="zend.ldap.usage.basic.delete">
108             <title>Supprimer de LDAP</title>
110             <example>
111                 <title>Supprimer une entrée existante de LDAP</title>
113                 <programlisting language="php"><![CDATA[
114 $options = array(/* ... */);
115 $ldap = new Zend_Ldap($options);
116 $ldap->bind();
117 $ldap->delete('cn=Hans Meier,ou=People,dc=my,dc=local');
118 ]]></programlisting>
119             </example>
120         </sect3>
122         <sect3 id="zend.ldap.usage.basic.update">
123             <title>Mettre à jour LDAP</title>
125             <example>
126                 <title>Mettre à jour une entrée existante dans LDAP</title>
128                 <programlisting language="php"><![CDATA[
129 $options = array(/* ... */);
130 $ldap = new Zend_Ldap($options);
131 $ldap->bind();
132 $hm = $ldap->getEntry('cn=Hugo Müller,ou=People,dc=my,dc=local');
133 Zend_Ldap_Attribute::setAttribute($hm, 'mail', 'mueller@my.local');
134 Zend_Ldap_Attribute::setPassword($hm,
135                                  'newPa$$w0rd',
136                                  Zend_Ldap_Attribute::PASSWORD_HASH_SHA1);
137 $ldap->update('cn=Hugo Müller,ou=People,dc=my,dc=local', $hm);
138 ]]></programlisting>
139             </example>
140         </sect3>
141     </sect2>
143     <sect2 id="zend.ldap.usage.extended">
144         <title>Opérations avancées</title>
146         <sect3 id="zend.ldap.usage.extended.copy-and-move">
147             <title>Copier et déplacer des entrées LDAP</title>
149             <example id="zend.ldap.usage.extended.copy-and-move.copy">
150                 <title>Copier une entrée LDAP récursivement avec tous ses descendants</title>
152                 <programlisting language="php"><![CDATA[
153 $options = array(/* ... */);
154 $ldap = new Zend_Ldap($options);
155 $ldap->bind();
156 $ldap->copy('cn=Hugo Müller,ou=People,dc=my,dc=local',
157             'cn=Hans Meier,ou=People,dc=my,dc=local',
158             true);
159 ]]></programlisting>
160             </example>
162             <example id="zend.ldap.usage.extended.copy-and-move.move-to-subtree">
163                 <title>
164                     Déplacer une entrée LDAP récursivement vers un sous-arbre différent
165                 </title>
167                 <programlisting language="php"><![CDATA[
168 $options = array(/* ... */);
169 $ldap = new Zend_Ldap($options);
170 $ldap->bind();
171 $ldap->moveToSubtree('cn=Hugo Müller,ou=People,dc=my,dc=local',
172                      'ou=Dismissed,dc=my,dc=local',
173                      true);
174 ]]></programlisting>
175             </example>
176         </sect3>
177     </sect2>
178 </sect1>