需要一种直接的方法来存储地址簿风格的数据和网络信息以及任何结构化数据吗? LDAP是一种可以追溯到1993年的技术,它提供了解决方案。虽然缺乏诸如Node.js和Go之类的新技术的“酷”因素,但其功能仍然很重要。
密钥概念:
1993年在密歇根大学创建的LDAP(轻量级目录访问协议)是用于管理目录服务的Internet协议。 它有效地存储和管理通讯录信息,网络详细信息和其他有组织的数据。“ LDAP”在技术上是指该协议,通常用于描述客户端和服务器组件。 将其视为目录服务器的SQL,即与LDAP启用服务器进行交互的语言。 流行的LDAP服务器包括Microsoft的Active Directory(自Windows 2000以来集成到Windows)和开源OpenLDAP,我们将在此教程系列中使用。 OpenLDAP的灵活性允许多样化的架构和数据存储。
>这第一部分涵盖:
> 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上的Wikipedia条目。
> 设置LDAP服务器:
>> OpenLDAP安装和配置可能有些复杂。 这些步骤针对基于Debian的服务器进行了优化,目的是为了清晰和简洁:
sudo apt-get install slapd ldap-utils
dpkg-reconfigure slapd
homestead.localdomain
>
验证:>
通过运行:检查安装
ldapsearch -x -b dc=homestead,dc=localdomain
>
sudo netstat -tlnp | grep slapd
填充数据库:
create
带有以下内容:>
users.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
(您将提示您输入管理员密码。)
ldapadd -x -W -D "cn=admin,dc=homestead,dc=localdomain" -f users.ldif
>使用:
验证记录(php互动,连接到服务器,搜索,更新和删除和删除,将在随后的部分中随后的部分,由于长度限制。)
以上是LDAP与PHP的要点的详细内容。更多信息请关注PHP中文网其他相关文章!