| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- Reviewed: no -->
- <!-- EN-Revision: 24249 -->
- <sect1 id="zend.ldap.usage">
- <title>利用シナリオ</title>
- <sect2 id="zend.ldap.usage.authentication">
- <title>認証シナリオ</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>基本的なCRUD操作</title>
- <sect3 id="zend.ldap.usage.basic.retrieve">
- <title>LDAPからデータを取得</title>
- <example id="zend.ldap.usage.basic.retrieve.dn">
- <title>その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 は下記の構造の配列
- 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>与えられたDNが存在するかチェック</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>与えられたDNの子供を数える</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>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>LDAPにデータを追加</title>
- <example>
- <title>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>LDAPからデータを削除</title>
- <example>
- <title>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>LDAPを更新</title>
- <example>
- <title>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>拡張された操作</title>
- <sect3 id="zend.ldap.usage.extended.copy-and-move">
- <title>LDAPで項目をコピーまたは移動</title>
- <example id="zend.ldap.usage.extended.copy-and-move.copy">
- <title>LDAP項目をその全ての派生物と共に再帰的にコピー</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>
- LDAP項目をその全ての派生物と共に再帰的に異なるサブツリーに移動
- </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>
|