1 <?xml version="1.0" encoding="UTF-8"?>
3 <!-- EN-Revision: 20792 -->
4 <sect1 id="zend.ldap.usage">
6 <sect2 id="zend.ldap.usage.authentication">
9 <sect3 id="zend.ldap.usage.authentication.openldap">
10 <title>OpenLDAP</title>
14 <sect3 id="zend.ldap.usage.authentication.activedirectory">
15 <title>ActiveDirectory</title>
20 <sect2 id="zend.ldap.usage.basic">
21 <title>基本的なCRUD操作</title>
23 <sect3 id="zend.ldap.usage.basic.retrieve">
24 <title>LDAPからデータを取得</title>
25 <example id="zend.ldap.usage.basic.retrieve.dn">
26 <title>そのDNで項目を取得</title>
27 <programlisting language="php"><![CDATA[
28 $options = array(/* ... */);
29 $ldap = new Zend_Ldap($options);
31 $hm = $ldap->getEntry('cn=Hugo Müller,ou=People,dc=my,dc=local');
35 'dn' => 'cn=Hugo Müller,ou=People,dc=my,dc=local',
36 'cn' => array('Hugo Müller'),
37 'sn' => array('Müller'),
38 'objectclass' => array('inetOrgPerson', 'top'),
45 <example id="zend.ldap.usage.basic.retrieve.exists">
46 <title>与えられたDNが存在するかチェック</title>
47 <programlisting language="php"><![CDATA[
48 $options = array(/* ... */);
49 $ldap = new Zend_Ldap($options);
51 $isThere = $ldap->exists('cn=Hugo Müller,ou=People,dc=my,dc=local');
55 <example id="zend.ldap.usage.basic.retrieve.counting-children">
56 <title>与えられたDNの子供を数える</title>
57 <programlisting language="php"><![CDATA[
58 $options = array(/* ... */);
59 $ldap = new Zend_Ldap($options);
61 $childrenCount = $ldap->countChildren(
62 'cn=Hugo Müller,ou=People,dc=my,dc=local');
66 <example id="zend.ldap.usage.basic.retrieve.search">
67 <title>LDAPツリーを検索</title>
68 <programlisting language="php"><![CDATA[
69 $options = array(/* ... */);
70 $ldap = new Zend_Ldap($options);
72 $result = $ldap->search('(objectclass=*)',
73 'ou=People,dc=my,dc=local',
74 Zend_Ldap_Ext::SEARCH_SCOPE_ONE);
75 foreach ($result as $item) {
76 echo $item["dn"] . ': ' . $item['cn'][0] . PHP_EOL;
82 <sect3 id="zend.ldap.usage.basic.add">
83 <title>LDAPにデータを追加</title>
85 <title>LDAPに新規項目を追加</title>
86 <programlisting language="php"><![CDATA[
87 $options = array(/* ... */);
88 $ldap = new Zend_Ldap($options);
91 Zend_Ldap_Attribute::setAttribute($entry, 'cn', 'Hans Meier');
92 Zend_Ldap_Attribute::setAttribute($entry, 'sn', 'Meier');
93 Zend_Ldap_Attribute::setAttribute($entry, 'objectClass', 'inetOrgPerson');
94 $ldap->add('cn=Hans Meier,ou=People,dc=my,dc=local', $entry);
99 <sect3 id="zend.ldap.usage.basic.delete">
100 <title>LDAPからデータを削除</title>
102 <title>LDAPから存在する項目を削除</title>
103 <programlisting language="php"><![CDATA[
104 $options = array(/* ... */);
105 $ldap = new Zend_Ldap($options);
107 $ldap->delete('cn=Hans Meier,ou=People,dc=my,dc=local');
112 <sect3 id="zend.ldap.usage.basic.update">
113 <title>LDAPを更新</title>
115 <title>LDAPに存在する項目を更新</title>
116 <programlisting language="php"><![CDATA[
117 $options = array(/* ... */);
118 $ldap = new Zend_Ldap($options);
120 $hm = $ldap->getEntry('cn=Hugo Müller,ou=People,dc=my,dc=local');
121 Zend_Ldap_Attribute::setAttribute($hm, 'mail', 'mueller@my.local');
122 Zend_Ldap_Attribute::setPassword($hm,
124 Zend_Ldap_Attribute::PASSWORD_HASH_SHA1);
125 $ldap->update('cn=Hugo Müller,ou=People,dc=my,dc=local', $hm);
131 <sect2 id="zend.ldap.usage.extended">
132 <title>拡張された操作</title>
134 <sect3 id="zend.ldap.usage.extended.copy-and-move">
135 <title>LDAPで項目をコピーまたは移動</title>
137 <example id="zend.ldap.usage.extended.copy-and-move.copy">
138 <title>LDAP項目をその全ての派生物と共に再帰的にコピー</title>
139 <programlisting language="php"><![CDATA[
140 $options = array(/* ... */);
141 $ldap = new Zend_Ldap($options);
143 $ldap->copy('cn=Hugo Müller,ou=People,dc=my,dc=local',
144 'cn=Hans Meier,ou=People,dc=my,dc=local',
149 <example id="zend.ldap.usage.extended.copy-and-move.move-to-subtree">
151 LDAP項目をその全ての派生物と共に再帰的に異なるサブツリーに移動
153 <programlisting language="php"><![CDATA[
154 $options = array(/* ... */);
155 $ldap = new Zend_Ldap($options);
157 $ldap->moveToSubtree('cn=Hugo Müller,ou=People,dc=my,dc=local',
158 'ou=Dismissed,dc=my,dc=local',