ホームページ >バックエンド開発 >PHPチュートリアル >PHPを使用したLDAPの必需品
構造化されたデータとともにアドレス帳スタイルのデータとネットワーク情報を保存するための簡単な方法が必要ですか? 1993年に遡るテクノロジーであるLDAPは、ソリューションを提供します。 node.jsやGoなどの新しいテクノロジーの「クールな」要因が不足していますが、その機能は非常に関連性が高いままです。
重要な概念:
1993年にミシガン大学で作成されたLDAP(LightWeight Directory Access Protocol)は、ディレクトリサービスを管理するためのインターネットプロトコルです。 アドレス帳の情報、ネットワークの詳細、およびその他の編成データを効率的に保存および管理しています。 広く使用されているオープンソースLDAPサーバーであるOpenLdapはスキーマに依存しているため、データ構造やコンテンツに制限を課さないことを意味します。 コマンドライン命令を使用して、Debianベースのシステムに簡単にインストールおよび構成されています。openldapセットアップの基本。
データレコードの読み込み。PHP。
を使用した基本操作の接続と実行の実行
本質的な用語:
先に進む前に、いくつかの重要な用語を明確にしましょう:
LDAP Term | Description |
---|---|
dn | Distinguished Name: A record's unique identifier, similar to a primary key in relational databases. |
Directory Schema | Defines the structure and constraints of the directory information. |
entry | A record containing attributes that store data. |
attribute | Similar to an associative array element or database column; specifies the data type, sorting rules, case-sensitivity, and other criteria. |
cn | Common Name (e.g., "John Smith") |
sn | Surname (e.g., "Smith") |
より深い理解については、O'ReillyのLDAPガイドまたはLDAPのウィキペディアエントリに相談してください。 LDAPサーバーのセットアップ
:
OpenLDAPのインストールと構成は多少複雑になる可能性があります。 Debianベースのサーバー向けに最適化されたこれらの手順は、明確さと簡潔さを目指しています:
<code class="language-bash">sudo apt-get install slapd ldap-utils</code>
<code class="language-bash">dpkg-reconfigure slapd</code>次のようにプロンプトに答えます:
homestead.localdomain
組織の名前:(組織名)実行してインストールを確認してください:
エラーが発生した場合は、OpenLDAPが実行されていることを確認してください:
<code class="language-bash">ldapsearch -x -b dc=homestead,dc=localdomain</code>
次のコンテンツを使用してを作成します
:<code class="language-bash">sudo netstat -tlnp | grep slapd</code>
データベースの入力:
users.ldif
<code class="language-ldif">dn: cn=Sheldon Cooper,ou=People,dc=homestead,dc=localdomain
cn: Sheldon Cooper
objectClass: person
objectClass: inetOrgPerson
sn: Cooper
dn: cn=Leonard Hofstadter,ou=People,dc=homestead,dc=localdomain
cn: Leonard Hofstadter
objectClass: person
objectClass: inetOrgPerson
sn: Hofstadter
dn: cn=Howard Wolowitz,ou=People,dc=homestead,dc=localdomain
cn: Howard Wolowitz
objectClass: person
objectClass: inetOrgPerson
sn: Wolowitz
dn: cn=Rajesh Koothrappali,ou=People,dc=homestead,dc=localdomain
cn: Rajesh Koothrappali
objectClass: person
objectClass: inetOrgPerson
sn: Koothrappali</code>
<code class="language-bash">ldapadd -x -W -D "cn=admin,dc=homestead,dc=localdomain" -f users.ldif</code>
(PHP相互作用、サーバーへの接続、長さの制限により、後続のセクションで検索、更新、削除が続きます。
以上がPHPを使用したLDAPの必需品の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。