Zend_Ldap-Usage.xml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <!-- EN-Revision: 24249 -->
  4. <sect1 id="zend.ldap.usage">
  5. <title>利用シナリオ</title>
  6. <sect2 id="zend.ldap.usage.authentication">
  7. <title>認証シナリオ</title>
  8. <sect3 id="zend.ldap.usage.authentication.openldap">
  9. <title>OpenLDAP</title>
  10. <para/>
  11. </sect3>
  12. <sect3 id="zend.ldap.usage.authentication.activedirectory">
  13. <title>ActiveDirectory</title>
  14. <para/>
  15. </sect3>
  16. </sect2>
  17. <sect2 id="zend.ldap.usage.basic">
  18. <title>基本的なCRUD操作</title>
  19. <sect3 id="zend.ldap.usage.basic.retrieve">
  20. <title>LDAPからデータを取得</title>
  21. <example id="zend.ldap.usage.basic.retrieve.dn">
  22. <title>そのDNで項目を取得</title>
  23. <programlisting language="php"><![CDATA[
  24. $options = array(/* ... */);
  25. $ldap = new Zend_Ldap($options);
  26. $ldap->bind();
  27. $hm = $ldap->getEntry('cn=Hugo Müller,ou=People,dc=my,dc=local');
  28. /*
  29. $hm は下記の構造の配列
  30. array(
  31. 'dn' => 'cn=Hugo Müller,ou=People,dc=my,dc=local',
  32. 'cn' => array('Hugo Müller'),
  33. 'sn' => array('Müller'),
  34. 'objectclass' => array('inetOrgPerson', 'top'),
  35. ...
  36. )
  37. */
  38. ]]></programlisting>
  39. </example>
  40. <example id="zend.ldap.usage.basic.retrieve.exists">
  41. <title>与えられたDNが存在するかチェック</title>
  42. <programlisting language="php"><![CDATA[
  43. $options = array(/* ... */);
  44. $ldap = new Zend_Ldap($options);
  45. $ldap->bind();
  46. $isThere = $ldap->exists('cn=Hugo Müller,ou=People,dc=my,dc=local');
  47. ]]></programlisting>
  48. </example>
  49. <example id="zend.ldap.usage.basic.retrieve.counting-children">
  50. <title>与えられたDNの子供を数える</title>
  51. <programlisting language="php"><![CDATA[
  52. $options = array(/* ... */);
  53. $ldap = new Zend_Ldap($options);
  54. $ldap->bind();
  55. $childrenCount = $ldap->countChildren(
  56. 'cn=Hugo Müller,ou=People,dc=my,dc=local');
  57. ]]></programlisting>
  58. </example>
  59. <example id="zend.ldap.usage.basic.retrieve.search">
  60. <title>LDAPツリーを検索</title>
  61. <programlisting language="php"><![CDATA[
  62. $options = array(/* ... */);
  63. $ldap = new Zend_Ldap($options);
  64. $ldap->bind();
  65. $result = $ldap->search('(objectclass=*)',
  66. 'ou=People,dc=my,dc=local',
  67. Zend_Ldap_Ext::SEARCH_SCOPE_ONE);
  68. foreach ($result as $item) {
  69. echo $item["dn"] . ': ' . $item['cn'][0] . PHP_EOL;
  70. }
  71. ]]></programlisting>
  72. </example>
  73. </sect3>
  74. <sect3 id="zend.ldap.usage.basic.add">
  75. <title>LDAPにデータを追加</title>
  76. <example>
  77. <title>LDAPに新規項目を追加</title>
  78. <programlisting language="php"><![CDATA[
  79. $options = array(/* ... */);
  80. $ldap = new Zend_Ldap($options);
  81. $ldap->bind();
  82. $entry = array();
  83. Zend_Ldap_Attribute::setAttribute($entry, 'cn', 'Hans Meier');
  84. Zend_Ldap_Attribute::setAttribute($entry, 'sn', 'Meier');
  85. Zend_Ldap_Attribute::setAttribute($entry, 'objectClass', 'inetOrgPerson');
  86. $ldap->add('cn=Hans Meier,ou=People,dc=my,dc=local', $entry);
  87. ]]></programlisting>
  88. </example>
  89. </sect3>
  90. <sect3 id="zend.ldap.usage.basic.delete">
  91. <title>LDAPからデータを削除</title>
  92. <example>
  93. <title>LDAPから存在する項目を削除</title>
  94. <programlisting language="php"><![CDATA[
  95. $options = array(/* ... */);
  96. $ldap = new Zend_Ldap($options);
  97. $ldap->bind();
  98. $ldap->delete('cn=Hans Meier,ou=People,dc=my,dc=local');
  99. ]]></programlisting>
  100. </example>
  101. </sect3>
  102. <sect3 id="zend.ldap.usage.basic.update">
  103. <title>LDAPを更新</title>
  104. <example>
  105. <title>LDAPに存在する項目を更新</title>
  106. <programlisting language="php"><![CDATA[
  107. $options = array(/* ... */);
  108. $ldap = new Zend_Ldap($options);
  109. $ldap->bind();
  110. $hm = $ldap->getEntry('cn=Hugo Müller,ou=People,dc=my,dc=local');
  111. Zend_Ldap_Attribute::setAttribute($hm, 'mail', 'mueller@my.local');
  112. Zend_Ldap_Attribute::setPassword($hm,
  113. 'newPa$$w0rd',
  114. Zend_Ldap_Attribute::PASSWORD_HASH_SHA1);
  115. $ldap->update('cn=Hugo Müller,ou=People,dc=my,dc=local', $hm);
  116. ]]></programlisting>
  117. </example>
  118. </sect3>
  119. </sect2>
  120. <sect2 id="zend.ldap.usage.extended">
  121. <title>拡張された操作</title>
  122. <sect3 id="zend.ldap.usage.extended.copy-and-move">
  123. <title>LDAPで項目をコピーまたは移動</title>
  124. <example id="zend.ldap.usage.extended.copy-and-move.copy">
  125. <title>LDAP項目をその全ての派生物と共に再帰的にコピー</title>
  126. <programlisting language="php"><![CDATA[
  127. $options = array(/* ... */);
  128. $ldap = new Zend_Ldap($options);
  129. $ldap->bind();
  130. $ldap->copy('cn=Hugo Müller,ou=People,dc=my,dc=local',
  131. 'cn=Hans Meier,ou=People,dc=my,dc=local',
  132. true);
  133. ]]></programlisting>
  134. </example>
  135. <example id="zend.ldap.usage.extended.copy-and-move.move-to-subtree">
  136. <title>
  137. LDAP項目をその全ての派生物と共に再帰的に異なるサブツリーに移動
  138. </title>
  139. <programlisting language="php"><![CDATA[
  140. $options = array(/* ... */);
  141. $ldap = new Zend_Ldap($options);
  142. $ldap->bind();
  143. $ldap->moveToSubtree('cn=Hugo Müller,ou=People,dc=my,dc=local',
  144. 'ou=Dismissed,dc=my,dc=local',
  145. true);
  146. ]]></programlisting>
  147. </example>
  148. </sect3>
  149. </sect2>
  150. </sect1>