ls -la /var/运行/ldapi

ls -la /var/运行/ldapi

(这是ldap_modify:更改密码时访问权限不足(50)因为我们在诊断过程中发现了一个单独的问题。)

在修改 cn=config LDAP 数据库之前,我尝试访问它。但是,我收到错误ldap_sasl_interactive_bind_s: Can't contact LDAP server (-1)

# ldapsearch -H ldapi:/// -Y EXTERNAL -b 'cn=config' -d1
ldap_url_parse_ext(ldapi:///)
ldap_create
ldap_url_parse_ext(ldapi:///??base)
ldap_sasl_interactive_bind: user selected: EXTERNAL
ldap_int_sasl_bind: EXTERNAL
ldap_new_connection 1 1 0
ldap_int_open_connection
ldap_connect_to_path
ldap_new_socket: 3
ldap_connect_to_path: Trying /var/run/ldapi
ldap_connect_timeout: fd: 3 tm: -1 async: 0
ldap_ndelay_on: 3
ldap_close_socket: 3
ldap_msgfree
ldap_err2string
ldap_sasl_interactive_bind_s: Can't contact LDAP server (-1)

ldapi://(但不是ldapi:///?)看起来定义在/etc/openldap/ldap.conf

#
# LDAP Defaults
#

# See ldap.conf(5) for details
# This file should be world readable but not world writable.

BASE    dc=my_domain,dc=com
#URI    ldap://ldap.example.com ldap://ldap-master.example.com:666
URI     ldap:// ldapi:// ldaps://

#SIZELIMIT  12
#TIMELIMIT  15
#DEREF          never

TLS_CACERTDIR /etc/openldap/certs

停止防火墙后,我收到相同的 ldap_sasl_interactive_bind_s:无法联系 LDAP 服务器(-1)错误(service iptables stop),所以防火墙不是问题。

ldapi 的套接字文件看起来未定义:

ls -la /var/运行/ldapi

ls:无法访问 /var/run/ldapi:没有此文件或目录

以下是 /var/run 中的其他文件:

[root@my_hostname ~]# ls -la /var/run/
total 128
drwxr-xr-x. 19 root      root      4096 Oct 30 13:13 .
drwxr-xr-x. 20 root      root      4096 Oct 20 09:23 ..
drwxr-xr-x.  2 root      root      4096 Oct 23 23:11 abrt
-rw-r--r--   1 root      root         5 Oct 23 23:11 abrtd.pid
-rw-r--r--   1 root      root         5 Oct 23 23:11 atd.pid
-rw-r--r--   1 root      root         4 Oct 23 23:11 auditd.pid
drwxr-xr-x.  2 root      root      4096 Aug 18 09:26 console
drwxr-xr-x.  2 root      root      4096 Nov 10  2010 ConsoleKit
-rw-r--r--   1 root      root         5 Oct 23 23:11 crond.pid
----------   1 root      root         0 Oct 23 23:11 cron.reboot
drwxr-xr-x.  2 root      root      4096 Oct 23 23:11 dbus
drwxr-xr-x   2 root      root      4096 Oct 23 23:11 fail2ban
drwxr-xr-x.  2 root      root      4096 Aug 18 09:26 faillock
drwx------.  2 haldaemon haldaemon 4096 Oct 15  2014 hald
-rw-r--r--   1 root      root         5 Oct 23 23:11 haldaemon.pid
-rw-r--r--   1 root      root         5 Oct 23 23:11 irqbalance.pid
drwx------.  2 root      root      4096 Sep 22 09:15 lvm
drwx------.  2 root      root      4096 Jul 24 03:23 mdadm
-rw-r--r--   1 root      root         5 Oct 23 23:11 messagebus.pid
drwxrwxr-x.  2 root      root      4096 Sep 22 11:47 netreport
drwxr-xr-x   2 ldap      ldap      4096 Oct 30 13:13 openldap
drwxr-xr-x.  2 root      root      4096 Aug 11  2014 plymouth
drwxr-xr-x.  4 root      root      4096 Oct 15  2014 pm-utils
drwxr-xr-x   2 root      root      4096 Oct 23 23:11 portreserve
drwxr-xr-x.  2 root      root      4096 Mar 25  2015 saslauthd
drwxr-xr-x.  2 root      root      4096 Aug 18 09:26 sepermit
drwxr-xr-x.  2 root      root      4096 Oct 15  2014 setrans
-rw-r--r--   2 ldap      ldap         6 Oct 30 13:13 slapd.pid
-rw-r--r--   1 root      root         5 Oct 23 23:11 sshd.pid
-rw-------   1 root      root         5 Oct 23 23:11 syslogd.pid
-rw-rw-r--   1 root      utmp      5376 Nov  3 11:16 utmp
-rw-r--r--   1 root      root         5 Oct 23 23:11 xe-daemon.pid

[root@my_hostname ~]# ls -la /var/run/openldap/
total 16
drwxr-xr-x   2 ldap ldap 4096 Oct 30 13:13 .
drwxr-xr-x. 19 root root 4096 Oct 30 13:13 ..
-rw-r--r--   1 ldap ldap   39 Oct 30 13:13 slapd.args
-rw-r--r--   2 ldap ldap    6 Oct 30 13:13 slapd.pid

slapd看起来它是用 ldaps 启动的,而不是用 ldapi 启动的:

# ps auxf | grep slapd
root     28776  0.0  0.0 103308   836 pts/0    S+   11:23   0:00          \_ grep slapd
ldap     29398  0.0  1.0 370152 20348 ?        Ssl  Oct30   0:00 /usr/sbin/slapd -h  ldaps:/// -u ldap

唯一提到 ldaps:在 /etc/openldap 中也提到了 ldapi:

# grep -R 'ldaps:' /etc/openldap/
/etc/openldap/ldap.conf:URI ldap:// ldapi:// ldaps://

我如何确保ldapi:///可用?

答案1

根据@84104 的评论,/etc/openldap/ldap.conf这是客户端配置。

CentOS6 上的服务器配置在/etc/sysconfig/ldap(不是slapd)。我确保它包含以下行:

# Run slapd with -h "... ldapi:/// ..."
#   yes/no, default: yes
SLAPD_LDAPI=yes

并重新启动 LDAP 服务器:

service slapd restart

此后,ldapi:///即可使用并ldapsearch -H ldapi:/// -Y EXTERNAL -b 'cn=config'成功。

相关内容