SDB:LDAP 服务器
使用 openSUSE 的 YaST2 进行基本安装有一些优势。然后你将获得一个基本的可用设置,其中包含正常操作所需的 LDAP 模式。
安装软件
- 使用你的软件包管理器添加 "yast2-auth-server" 模块。
- 重启 YaST 并进入网络服务,启动“身份验证服务器”模块。
- 选择启动 LDAP 服务器并选择配置。
- 选择安装独立服务器、主服务器还是副本服务器。
- 选择是否启用 TLS。强烈建议这样做,但需要安装证书。
- 选择“数据库”然后“添加”。
- 选择形式为 "dc=example,dc=com" 或 "dc=test,dc=example,dc=com" 的 Base-DN。这通常会模拟你的网络域,例如 example.com 或 test.example.com。或者,如果你不在互联网上,可以使用 dc=local。
- 为管理员选择密码,然后点击“确定”。
- 你现在也可以设置 Kerberos 身份验证(此处未说明)。
测试你的 LDAP 服务器,启动和停止
你必须能够(重新)启动你的 LDAP 服务器。像这样测试它
# stop your ldap server
systemctl stop slapd.service
# start your ldap server
systemctl start slapd.service
# verify your ldap server is running
systemctl status slapd.service
你的 LDAP 服务器必须可以通过网络访问。要检查此操作,请运行此命令
nmap localhost | grep -P '389|636'
此命令的响应应包含一行
389/tcp open ldap
连接
要测试你的数据库是否正确设置,请输入
slapcat
你应该收到如下响应
dn: dc=example,dc=com
dc: example
o: example
objectClass: organization
objectClass: dcObject
structuralObjectClass: organization
entryUUID: 7ab95c2e-0c8f-102d-9e51-5b50a42d05ab
creatorsName: cn=Administrator,dc=example,dc=com
createTimestamp: 20080901163340Z
entryCSN: 20080901163340Z#000000#00#000000
modifiersName: cn=Administrator,dc=example,dc=com
modifyTimestamp: 20080901163340Z
添加 OU
此示例假定你选择了 dc=example,dc=com 作为 base DN。要添加组织单元,请执行以下操作
# stop your ldap server
systemctl stop slapd.service
# then create a file and add its content to your directory
cat >orgunit<<EOF
dn: ou=orgunit1,dc=example,dc=com
objectClass: top
objectClass: organizationalUnit
ou: orgunit1
description: Test orgUnit
EOF
slapadd -v -l orgunit
# start your ldap server
systemctl start slapd.service
你应该收到如下响应
added: "ou=orgunit1,dc=example,dc=com" (00000002)
添加人员
此示例假定你已添加 orgunit1,如上所述。要将人员添加到目录,请运行此代码
cat >person<<EOF
dn: cn=James Attah,ou=orgunit1,dc=Amaglobal,dc=local
objectclass: top
objectclass: person
objectclass: organizationalPerson
sn: James
cn: James Attah
EOF
slapadd -v -l person
使用应用程序
现在你可以使用例如 kaddressbook 测试你的 ldap 服务器。搜索“John”,你将找到 John Johnson。