开始新的 openldap 安装

start new openldap installation

我正在 Centos7 上从头开始安装 openldap

我遵循了 openldap.org 网站上的快速入门指南 http://www.openldap.org/doc/admin24/quickstart.html

在第 7 步之前一切正常,我在自定义目录中安装 openldap 没有问题

下面是我的命令 运行

cd /usr/local/src
mkdir openldap
cd openldap
cp /home/user/openldap/src/* . //copied everything in the tar ball to the directory
yum install gcc openssl libdb-devel libtool-ltdl-devel.x86_64 openssl-devel.x86_64 cyrus-sasl-devel.x86_64
//yum installed every required package, including devel package for make
./configure --prefix=/usr/local/src/openldap-install   //configure to install in custom location
make depend
make
make test //all successful
make install

然后我尝试按照第 8 步,编辑 slapd.ldif 以放入我自己的域, dc=adomain,dc=com ,在我的例子中,在 /usr/local/src/openldap-install/etc/openldap/slapd.ldif

然后我将 /usr/local/src/openldap-install/sbin/ 目录添加到 PATH 环境,通过在 profile.d 目录中插入 openldap_path.sh,验证它是否有效。

然后我按照第 9 步进行操作,(我是 运行 root 的一切)

slapadd -F /usr/local/etc/cn=config -l /usr/local/etc/openldap/slapd.ldif

但它返回 "available database(s) do not allow slapadd new server"

我不明白,我没有迁移(如其他一些 Whosebug post 中所建议),它是一个 b运行d 新服务器,但它不允许我继续.

任何帮助将不胜感激,我只是不知道下一步该做什么。

@EJP

文件如下

#
# See slapd-config(5) for details on configuration options.
# This file should NOT be world readable.
#
dn: cn=config
objectClass: olcGlobal
cn: config
#
#
# Define global ACLs to disable default read access.
#
olcArgsFile: /usr/local/src/openldap-install/var/run/slapd.args
olcPidFile: /usr/local/src/openldap-install/var/run/slapd.pid
#
# Do not enable referrals until AFTER you have a working directory
# service AND an understanding of referrals.
#olcReferral:   ldap://root.openldap.org
#
# Sample security restrictions
#   Require integrity protection (prevent hijacking)
#   Require 112-bit (3DES or better) encryption for updates
#   Require 64-bit encryption for simple bind
#olcSecurity: ssf=1 update_ssf=112 simple_bind=64


#
# Load dynamic backend modules:
#
#dn: cn=module,cn=config
#objectClass: olcModuleList
#cn: module
#olcModulepath: /usr/local/src/openldap-install/libexec/openldap
#olcModuleload: back_bdb.la
#olcModuleload: back_hdb.la
#olcModuleload: back_ldap.la
#olcModuleload: back_passwd.la
#olcModuleload: back_shell.la


dn: cn=schema,cn=config
objectClass: olcSchemaConfig
cn: schema

include: file:///usr/local/src/openldap-install/etc/openldap/schema/core.ldif

# Frontend settings
#
dn: olcDatabase=frontend,cn=config
objectClass: olcDatabaseConfig
objectClass: olcFrontendConfig
olcDatabase: frontend
#
# Sample global access control policy:
#   Root DSE: allow anyone to read it
#   Subschema (sub)entry DSE: allow anyone to read it
#   Other DSEs:
#       Allow self write access
#       Allow authenticated users read access
#       Allow anonymous users to authenticate
#
#olcAccess: to dn.base="" by * read
#olcAccess: to dn.base="cn=Subschema" by * read
#olcAccess: to *
#   by self write
#   by users read
#   by anonymous auth
#
# if no access controls are present, the default policy
# allows anyone and everyone to read anything but restricts
# updates to rootdn.  (e.g., "access to * by * read")
#
# rootdn can always read and write EVERYTHING!
#


#######################################################################
# LMDB database definitions
#######################################################################
#
dn: olcDatabase=mdb,cn=config
objectClass: olcDatabaseConfig
objectClass: olcMdbConfig
olcDatabase: mdb
**olcSuffix: dc=ldap,dc=domain,dc=com**
**olcRootDN: cn=Manager,dc=ldap,dc=domain,dc=com**
# Cleartext passwords, especially for the rootdn, should
# be avoided.  See slappasswd(8) and slapd-config(5) for details.
# Use of strong authentication encouraged.
**olcRootPW: {SSHA}strong**
# The database directory MUST exist prior to running slapd AND 
# should only be accessible by the slapd and slap tools.
# Mode 700 recommended.
**olcDbDirectory:   /usr/local/src/openldap-install/var/openldap-data**
# Indices to maintain
olcDbIndex: objectClass eq

仅更改了 slapd.ldif.default 文件的最后几行

以下是ls -R输出的安装路径下的文件树

.:
bin  etc  include  lib  libexec  sbin  share  var

./bin:
ldapadd      ldapdelete  ldapmodify  ldappasswd  ldapurl
ldapcompare  ldapexop    ldapmodrdn  ldapsearch  ldapwhoami

./etc:
openldap

./etc/openldap:
ldap.conf          schema      slapd.conf.default  slapd.ldif.default
ldap.conf.default  slapd.conf  slapd.ldif

./etc/openldap/schema:
collective.ldif    cosine.schema         java.ldif      openldap.schema
collective.schema  duaconf.ldif          java.schema    pmi.ldif
corba.ldif         duaconf.schema        misc.ldif      pmi.schema
corba.schema       dyngroup.ldif         misc.schema    ppolicy.ldif
core.ldif          dyngroup.schema       nis.ldif       ppolicy.schema
core.schema        inetorgperson.ldif    nis.schema     README
cosine.ldif        inetorgperson.schema  openldap.ldif

./include:
lber.h        ldap_cdefs.h     ldap.h         ldap_utf8.h  slapi-plugin.h
lber_types.h  ldap_features.h  ldap_schema.h  ldif.h

./lib:
liblber-2.4.so.2       libldap-2.4.so.2       libldap_r-2.4.so.2.10.7
liblber-2.4.so.2.10.7  libldap-2.4.so.2.10.7  libldap_r.a
liblber.a              libldap.a              libldap_r.la
liblber.la             libldap.la             libldap_r.so
liblber.so             libldap_r-2.4.so.2     libldap.so

./libexec:
slapd

./sbin:
slapacl  slapauth  slapdn     slappasswd  slaptest
slapadd  slapcat   slapindex  slapschema

./share:
man

./share/man:
man1  man3  man5  man8

./share/man/man1:
ldapadd.1      ldapdelete.1  ldapmodify.1  ldappasswd.1  ldapurl.1
ldapcompare.1  ldapexop.1    ldapmodrdn.1  ldapsearch.1  ldapwhoami.1

./share/man/man3:
ber_alloc_t.3                ldap_free_urldesc.3
blablablablabla
blablablablabla
blablablablabla

./share/man/man5:
ldap.conf.5       slapd-mdb.5       slapd-sql.5         slapo-ppolicy.5
blablablablabla
blablablablabla
blablablablabla

./share/man/man8:
blablablablabla
blablablablabla

./var:
run

./var/run:

编辑

@EJP 我有点明白你的意思了。你是说默认的 LDIF 文件实际上是 cn=config 数据库?

我几乎要放弃了,我花了 1 周时间却没有启动 ldap 服务器。我看不出有什么问题,也许清理我的一些概念实际上可以解决这里的问题?

谢谢 EJP 对我的耐心等待,我知道我遗漏了一些非常微不足道的东西,但请相信我,我已经在互联网上搜索了好几天(在书店搜索了一天)都没有找到明确的答案。如果你能通过回答我的问题或你自己的解释来澄清一些概念,或者只提供一个我可以执行 slapadd 的虚拟 ldif 文件,然后我就能找出问题所在,那就太好了。

我把我的困难归咎于我认为 openldap 指导文档做得不好:

原来这个答案解决了问题Openldap naming context issue with Apache directory studio?

我想我很感激人们可以回答我的问题的一些细节或提供一个例子来回答。并非所有人都通过文字解释来学习,有些人通过示例和逆向工程来学习。阅读手册,只有当你不明白的时候才提出问题,我认为这是一个事先声明,而且大多数人在真正提出任何问题之前已经过了那个阶段。

是的,我想我应该问 serverfault,因为 Whosebug 更适合编程。

您应该将默认的 slapd.conf 目录格式转换为新的 slapd.d 目录格式。在 slapd.conf:

添加配置数据库定义
# before the first database definition
database config
# NOTE: the suffix is hardcoded as cn=config and 
# MUST not have a suffix directive
# normal rules apply - rootdn can be anything you want
# but MUST be under cn=config
rootdn "cn=admin,cn=config"
# use any of the supported password formats e.g. {SSHA} etc
# or plaintext as shown
rootpw config

然后使用

转换它
slaptest -f /usr/local/etc/openldap/slapd.conf -F /usr/local/etc/openldap/slapd.d

然后删除slapd.conf。然后您可以使用 slapadd 继续您的配置。看看Configuration Guide or http://www.zytrax.com/books/ldap/ch6/slapd-config.html.

希望对您有所帮助。

当我遇到同样的错误时,我没有弄清楚为什么 slapadd 命令失败。但是,如果你想让你的 LDAP 服务器正常工作,我可以分享我所做的。

步骤 1:直接在 slapd.conf 文件中配置 MDB。

安装 OpenLDAP 时,/usr/local/etc/openldap 下的 slapd.conf 文件已经创建并配置了 MDB 数据库。您可以根据需要更改 MDB 设置。这是默认设置:

#######################################################################
# MDB database definitions
#######################################################################

database    mdb
maxsize     1073741824
suffix      "dc=my-domain,dc=com"
rootdn      "cn=Manager,dc=my-domain,dc=com"
# Cleartext passwords, especially for the rootdn, should
# be avoid.  See slappasswd(8) and slapd.conf(5) for details.
# Use of strong authentication encouraged.
rootpw      secret
# The database directory MUST exist prior to running slapd AND 
# should only be accessible by the slapd and slap tools.
# Mode 700 recommended.
directory   /usr/local/var/openldap-data
# Indices to maintain
index   objectClass eq

第二步:配置完成后启动slapd。 启动 slapd 的命令:

/usr/local/libexec/slapd -d 1

如果看到"slapd starting",则表示slapd已启动。

步骤 3:创建数据库条目。

可以参考OpenLDAP Administrator guide中给出的过程:

1.Create an entries.ldif file like this:

    # Organization for Example Corporation
    dn: dc=example,dc=com
    objectClass: dcObject
    objectClass: organization
    dc: example
    o: Example Corporation
    description: The Example Corporation

    # Organizational Role for Directory Manager
    dn: cn=Manager,dc=example,dc=com
    objectClass: organizationalRole
    cn: Manager
    description: Directory Manager

2.Create the entries with ldapadd tool:

ldapadd -f entries.ldif -x -D "cn=Manager,dc=example,dc=com" -w secret

完成上面的 3 个步骤后,LDAP 服务器就可以使用了。您可以添加 DIT 供您使用。

仅供参考,一个好的 GUI 客户端可以帮助你很多。我用了 Jarek Gawor’s excellent LDAP Browser/Editor v2.8.2

希望这个回答对您或以后的其他人有所帮助。

我只是 运行 使用 OpenLDAP 2.6.0 进行此操作;在“configuremakemake install”之后,我无法 运行 slapd,服务器启动失败,“第 72 行的未知文件”

原来它没有创建 /usr/local/var/openldap-data/ 目录。

mkdir /usr/local/var/openldap-data/ 解决了。