1.安装
1.1 查看
# yum list | grep openldap
1.2 安装
# yum install openldap*
2.配置
2.1 创建slapd.config配置文件
# cp /usr/share/openldap-servers/slapd.conf.obsolete /etc/openldap/slapd.conf
2.2 修改密码
# slappasswd New password: secret Re-enter new password: secret {SSHA}Hy/MUWmZlIXWawK6uZxWprMU0FErCLnU
2.3 修改slapd.config文件
# vi /etc/openldap/slapd.conf
修改dc和rootpw,如下:
改前:
database bdb suffix "dc=my-domain,dc=com" checkpoint 1024 15 rootdn "cn=Manager,dc=my-domain,dc=com" # Cleartext passwords, especially for the rootdn, should # be avoided. See slappasswd(8) and slapd.conf(5) for details. # Use of strong authentication encouraged. # rootpw secret # rootpw {crypt}ijFYNcSNctBYg
改后:
database bdb suffix "dc=my-domain,dc=com" checkpoint 1024 15 rootdn "cn=Manager,dc=my-domain,dc=com" # Cleartext passwords, especially for the rootdn, should # be avoided. See slappasswd(8) and slapd.conf(5) for details. # Use of strong authentication encouraged. # rootpw secret rootpw {SSHA}Hy/MUWmZlIXWawK6uZxWprMU0FErCLnU
2.4 重新生成/etc/openldap/slapd.d目录
# rm -rf slapd.d/*
# slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d bdb_db_open: warning - no DB_CONFIG file found in directory /var/lib/ldap: (2). Expect poor performance for suffix "dc=my-domain,dc=com". bdb_db_open: database "dc=my-domain,dc=com": db_open(/var/lib/ldap/id2entry.bdb) failed: No such file or directory (2). backend_startup_one (type=bdb, suffix="dc=my-domain,dc=com"): bi_db_open failed! (2) slap_startup failed (test would succeed using the -u switch)
2.5 修改/etc/openldap/slapd.d/目录权限
# chown ldap:ldap -R /etc/openldap/slapd.d
2.6 修改/var/lib/ldap/目录权限
# chown ldap:ldap -R /var/lib/ldap/
3. 启动slapd服务
# /etc/init.d/slapd start ln: creating hard link `/var/run/slapd.pid': File exists [ OK ]
# telnet localhost 389 Trying ::1... Connected to localhost. Escape character is '^]'.
# ldapsearch -x # extended LDIF # # LDAPv3 # base <> (default) with scope subtree # filter: (objectclass=*) # requesting: ALL # # search result search: 2 result: 32 No such object