ldap的简介
LDAP是轻量目录访问协议,英文全称是Lightweight Directory Access Protocol,一般都简称为LDAP。它是基于X.500标准的,但是简单多了并且可以根据需要定制。与X.500不同,LDAP支持TCP/IP,这对访问Internet是必须的。LDAP的核心规范在RFC中都有定义,所有与LDAP相关的RFC都可以在LDAPman RFC网页中找到。
选择一个域名
我个人的域名为linuxpanda.tech,我给ldap服务配置一个域名为ldap.aibeike.com。通过dns解析添加一个A记录值为我自己的ldap服务器的外网ip。
测试域名正确性。
安装openldap服务端
1.关闭防火墙
systemctl stop firewalld
selinux disabled
2.安装软件:
yum -y install openldap compat-openldap openldap-clients openldap-servers openldap-servers-sql openldap-devel migrationtools
3.查看OpenLDAP版本,使用如下命令:slapd -VV
备份slapd.d文件 mv slapd.d slapd.d.bak
4.配置OpenLDAP管理员密码:
slappasswd -s [password] #[password]是管理密码 生成加密后的密码复制出来,后面会用
拷贝/usr/share/openldap-servers/slapd.ldif /etc/openldap/
编辑/etc/openldap/slapd.ldif 修改以下此处
olcSuffix: dc=xiodi,dc=cn
olcRootDN: cn=xiodiadmin,dc=xiodi,dc=cn
olcRootPW: {SSHA}dXgO/Ipy5SQiKFZ0u7m79Xo7uzKIr038 #上面生成的密码
al,cn=auth” read by dn.base=”cn=xiodiadmin,dc=xiodi,dc=cn” read by * none
验证OpenLDAP的基本配置是否正确,使用如下命令:slaptest -u
5.添加基础的schema:
include: file:///etc/openldap/schema/core.ldif 一定要放在第一行
include: file:///etc/openldap/schema/collective.ldif
include: file:///etc/openldap/schema/corba.ldif
include: file:///etc/openldap/schema/cosine.ldif
include: file:///etc/openldap/schema/duaconf.ldif
include: file:///etc/openldap/schema/dyngroup.ldif
include: file:///etc/openldap/schema/inetorgperson.ldif
include: file:///etc/openldap/schema/java.ldif
include: file:///etc/openldap/schema/misc.ldif
include: file:///etc/openldap/schema/nis.ldif
include: file:///etc/openldap/schema/openldap.ldif
include: file:///etc/openldap/schema/pmi.ldif
include: file:///etc/openldap/schema/ppolicy.ldif
6.拷贝数据库默认配置文件:
cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
初始化数据库
slapadd -n 0 -F slapd.d -l slapd.ldif
修改权限:
chown -R ldap.ldap slapd.d
chown -R ldap.ldap /var/lib/ldap
启动服务:
systemctl start slapd
查看状态:
systemctl status slapd
设置开启自启:
systemctl enable slapd
配置基本域:
touch /etc/openldap/config_init.ldif
编辑config_init.ldif:
dn: dc=xiodi,dc=cn
objectClass: dcObject
objectclass: organization
o: aishangwei
dc: xiodi
ldapadd -x -D “cn=xiodiadmin,dc=xiodi,dc=cn” -W -f config_init.ldif
输入上面的输入的密码
7.配置日志
[root@VM_0_15_centos myself]# vim log.ldif
[root@VM_0_15_centos myself]# cat log.ldif
dn: cn=config
changetype: modify
add: olcLogLevel
olcLogLevel: 32
“log.ldif” [New] 4L, 66C written
[root@VM_0_15_centos myself]# ldapmodify -Y EXTERNAL -H ldapi:/// -f log.ldif
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry “cn=config”
[root@VM_0_15_centos myself]# mkdir -p /var/log/slapd
[root@VM_0_15_centos myself]# chown ldap:ldap /var/log/slapd/
[root@VM_0_15_centos myself]# echo “local4.* /var/log/slapd/slapd.log” >> /etc/rsyslog.conf
[root@VM_0_15_centos myself]# systemctl restart rsyslog
[root@VM_0_15_centos myself]# systemctl restart slapd
[root@VM_0_15_centos myself]# tail -n 4 /var/log/slapd/slapd.log
Sep 5 20:43:31 VM_0_15_centos slapd[4520]: => test_filter
Sep 5 20:43:31 VM_0_15_centos slapd[4520]: PRESENT
Sep 5 20:43:31 VM_0_15_centos slapd[4520]: <= test_filter 6
Sep 5 20:43:31 VM_0_15_centos slapd[4523]: slapd starting
8.工具连接
图形操作界面有很多种,包括ldapadmin、ldapadmin.exe,当然还有其他的,这个步骤比较简单,就不详细讲解了。
本文介绍了如何安装和配置LDAP服务器,包括选择域名、安装openldap服务端的详细步骤,如关闭防火墙、安装相关软件、配置管理员密码、初始化数据库等,以及日志配置和使用工具进行连接。
3296

被折叠的 条评论
为什么被折叠?



