|
|
@@ -4,22 +4,26 @@
|
|
|
<title>Usage Scenarios</title>
|
|
|
<sect2 id="zend.ldap.usage.authentication">
|
|
|
<title>Authentication scenarios</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>Basic CRUD operations</title>
|
|
|
+
|
|
|
<sect3 id="zend.ldap.usage.basic.retrieve">
|
|
|
<title>Retrieving data from the LDAP</title>
|
|
|
<example id="zend.ldap.usage.basic.retrieve.dn">
|
|
|
- <title>Getting an entry by its DN</title>
|
|
|
-<programlisting role="php"><![CDATA[
|
|
|
+ <title>Getting an entry by its DN</title>
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
$options = array(/* ... */);
|
|
|
$ldap = new Zend_Ldap($options);
|
|
|
$ldap->bind();
|
|
|
@@ -39,7 +43,7 @@ array(
|
|
|
|
|
|
<example id="zend.ldap.usage.basic.retrieve.exists">
|
|
|
<title>Check for the existence of a given DN</title>
|
|
|
-<programlisting role="php"><![CDATA[
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
$options = array(/* ... */);
|
|
|
$ldap = new Zend_Ldap($options);
|
|
|
$ldap->bind();
|
|
|
@@ -49,32 +53,36 @@ $isThere = $ldap->exists('cn=Hugo Müller,ou=People,dc=my,dc=local');
|
|
|
|
|
|
<example id="zend.ldap.usage.basic.retrieve.counting-children">
|
|
|
<title>Count children of a given DN</title>
|
|
|
-<programlisting role="php"><![CDATA[
|
|
|
+ <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');
|
|
|
+$childrenCount = $ldap->countChildren(
|
|
|
+ 'cn=Hugo Müller,ou=People,dc=my,dc=local');
|
|
|
]]></programlisting>
|
|
|
</example>
|
|
|
|
|
|
<example id="zend.ldap.usage.basic.retrieve.search">
|
|
|
<title>Searching the LDAP tree</title>
|
|
|
-<programlisting role="php"><![CDATA[
|
|
|
+ <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);
|
|
|
+$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>Adding data to the LDAP</title>
|
|
|
<example>
|
|
|
- <title>Add a new entry to the LDAP</title>
|
|
|
-<programlisting role="php"><![CDATA[
|
|
|
+ <title>Add a new entry to the LDAP</title>
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
$options = array(/* ... */);
|
|
|
$ldap = new Zend_Ldap($options);
|
|
|
$ldap->bind();
|
|
|
@@ -86,11 +94,12 @@ $ldap->add('cn=Hans Meier,ou=People,dc=my,dc=local', $entry);
|
|
|
]]></programlisting>
|
|
|
</example>
|
|
|
</sect3>
|
|
|
+
|
|
|
<sect3 id="zend.ldap.usage.basic.delete">
|
|
|
<title>Deleting from the LDAP</title>
|
|
|
<example>
|
|
|
- <title>Delete an existing entry from the LDAP</title>
|
|
|
-<programlisting role="php"><![CDATA[
|
|
|
+ <title>Delete an existing entry from the LDAP</title>
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
$options = array(/* ... */);
|
|
|
$ldap = new Zend_Ldap($options);
|
|
|
$ldap->bind();
|
|
|
@@ -98,46 +107,57 @@ $ldap->delete('cn=Hans Meier,ou=People,dc=my,dc=local');
|
|
|
]]></programlisting>
|
|
|
</example>
|
|
|
</sect3>
|
|
|
+
|
|
|
<sect3 id="zend.ldap.usage.basic.update">
|
|
|
<title>Updating the LDAP</title>
|
|
|
<example>
|
|
|
- <title>Update an existing entry on the LDAP</title>
|
|
|
-<programlisting role="php"><![CDATA[
|
|
|
+ <title>Update an existing entry on the 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);
|
|
|
+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>Extended operations</title>
|
|
|
+
|
|
|
<sect3 id="zend.ldap.usage.extended.copy-and-move">
|
|
|
<title>Copy and move entries in the LDAP</title>
|
|
|
|
|
|
- <example id="zend.ldap.usage.extended.copy-and-move.copy">
|
|
|
- <title>Copy a LDAP entry recursively with all its descendants.</title>
|
|
|
-<programlisting role="php"><![CDATA[
|
|
|
+ <example id="zend.ldap.usage.extended.copy-and-move.copy">
|
|
|
+ <title>Copy a LDAP entry recursively with all its 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);
|
|
|
+$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>
|
|
|
|
|
|
- <example id="zend.ldap.usage.extended.copy-and-move.move-to-subtree">
|
|
|
- <title>Move a LDAP entry recursively with all its descendants to a different subtree.</title>
|
|
|
-<programlisting role="php"><![CDATA[
|
|
|
+ <example id="zend.ldap.usage.extended.copy-and-move.move-to-subtree">
|
|
|
+ <title>
|
|
|
+ Move a LDAP entry recursively with all its descendants to a different subtree
|
|
|
+ </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);
|
|
|
+$ldap->moveToSubtree('cn=Hugo Müller,ou=People,dc=my,dc=local',
|
|
|
+ 'ou=Dismissed,dc=my,dc=local',
|
|
|
+ true);
|
|
|
]]></programlisting>
|
|
|
- </example>
|
|
|
+ </example>
|
|
|
|
|
|
</sect3>
|
|
|
</sect2>
|