前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Converting slapd.conf to a Directory Based Configu

Converting slapd.conf to a Directory Based Configu

作者头像
明哥的运维笔记
发布2019-01-30 10:51:27
1K0
发布2019-01-30 10:51:27
举报
文章被收录于专栏:运维笔记运维笔记运维笔记

OpenLDAP 2.4

OpenLDAP 2.4 provides some great new features over 2.3. Notable among them are the ability to store configuration data in the directory and change values on the fly.

Adding a Schema


Converting slapd.conf to a Directory Based Configuration

OpenLDAP 2.4 maintains an LDIF-based online directory in /etc/openldap/slapd.d/ (or otherwise specified location). In order to use this, you must seed the directory one of two ways. One way is to convert an existing slapd.conf file, which is illustrated below. Note that to access the newly minted cn=config, you should create an entry in your slapd.conf to provide a root password to this entry, or otherwise provide a useful ACL/ACI which gives a user access.

To convert a standard slapd.conf file to the new format, issue the following command (re: man slapd-config):

slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d

Note that the directory /etc/openldap/slapd.d must exist prior to this command successfully completing.

After importing the config file, start the OpenLDAP server:

  • /etc/init.d/ldap start

Verify that the server is running:

  • ldapsearch -x -b '' -s base '(objectclass=*)' namingContexts

After validating that the server will start and stop, import some data with an LDIF file:

  • slapadd -l <file>.ldif

When attempting this, I get an error about an invalid attribute for an objectclass:

# slapadd -l slapcat.out 
str2entry: invalid value for attributeType objectClass #1 (syntax 1.3.6.1.4.1.1466.115.121.1.38)
slapadd: could not parse entry (line=1)
  • Missing a schema, had to add cosine schema to get this to work.

When attempting to add the schema ldif, I get this error:

# ldapadd -x -H ldap://locahost -D "cn=manager,dc=example,dc=org" -W -f core.ldif 
Enter LDAP Password: 
ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)

I switched back to using the slapd.conf file to get this to work, and emptying out the /var/lib/openldap-data directory, reattempting the slapadd, I get the following:

# slapadd -l backup.ldif
bdb_db_open: warning - no DB_CONFIG file found in directory /var/lib/openldap-data: (2).
Expect poor performance for suffix "dc=example,dc=org".
<= str2entry: str2ad(pwdHistory): attribute type undefined
slapadd: could not parse entry (line=79)
  • Missing ppolicy overlay.

``

Adding some schemas:

# ldapadd -x -H ldap://localhost/ -D "cn=config" -W -f schema/archive/cosine.ldif 
Enter LDAP Password: 
adding new entry "cn=cosine,cn=schema,cn=config"

# ldapadd -x -H ldap://localhost/ -D "cn=config" -W -f schema/archive/inetorgperson.ldif 
Enter LDAP Password: 
adding new entry "cn=inetorgperson,cn=schema,cn=config"

# ldapadd -x -H ldap://localhost/ -D "cn=config" -W -f schema/archive/nis.ldif 
Enter LDAP Password: 
adding new entry "cn=nis,cn=schema,cn=config"

# ldapadd -x -H ldap://localhost/ -D "cn=config" -W -f schema/archive/openldap.ldif 
Enter LDAP Password: 
adding new entry "cn=openldap,cn=schema,cn=config"

``

Note that you cannot (as of version 2.4.7) use slapindex to generate the cn=config configuration, use slaptest:

# cd /etc/openldap
# mkdir slapd.d
# /usr/sbin/slapindex -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d
# echo $?
0

Program exits without error.

# ls /etc/openldap/slapd.d

Subsequently, running this command immediately after generates the appropriate
cn=config:

# slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d
config file testing succeeded
# ll slapd.d
total 8
drwxr-x--- 4 root root 4096 Jan 10 13:07 cn=config
-rw------- 1 root root 1097 Jan 10 13:07 cn=config.ldif

I have filed an ITS with the OpenLDAP project for this (ITS#5321).


``

Querying cn=config

A sample query:

ldapsearch -x -H ldap://localhost/ -D "cn=config" -b 'cn=config' -W cn=config
Enter LDAP Password: 
# extended LDIF
#
# LDAPv3
# base <cn=config> with scope subtree
# filter: cn=config
# requesting: ALL
#

# config
dn: cn=config
objectClass: olcGlobal
cn: config
olcConfigFile: /etc/openldap/slapd.conf.WORKING
olcConfigDir: /etc/openldap/slapd.d
olcArgsFile: /var/run/openldap/run/slapd.args
olcAttributeOptions: lang-
olcAuthzPolicy: none
olcConcurrency: 0
olcConnMaxPending: 100
olcConnMaxPendingAuth: 1000
olcGentleHUP: FALSE
olcIdleTimeout: 0
olcIndexSubstrIfMaxLen: 4
olcIndexSubstrIfMinLen: 2
olcIndexSubstrAnyLen: 4
olcIndexSubstrAnyStep: 2
olcLocalSSF: 71
olcLogLevel: Any
olcPidFile: /var/run/openldap/run/slapd.pid
olcReadOnly: FALSE
olcSaslSecProps: noplain,noanonymous
olcSockbufMaxIncoming: 262143
olcSockbufMaxIncomingAuth: 16777215
olcThreads: 16
olcToolThreads: 1

# search result
search: 2
result: 0 Success

# numResponses: 2
# numEntries: 1

``

Query cn=schema:

ldapsearch -x -H ldap://localhost/ -D "cn=config" -b 'cn=schema,cn=config' -W

``

Query cn=config for olcDatabase entries:

Note that this searches for the second database, which is of type bdb.

ldapsearch -x -H ldap://localhost/ -D "cn=config" -b 'olcDatabase={1}bdb,cn=config' -W -LLL

``

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2015-03-13,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • OpenLDAP 2.4
    • Converting slapd.conf to a Directory Based Configuration
      • Querying cn=config
      相关产品与服务
      数据库
      云数据库为企业提供了完善的关系型数据库、非关系型数据库、分析型数据库和数据库生态工具。您可以通过产品选择和组合搭建,轻松实现高可靠、高可用性、高性能等数据库需求。云数据库服务也可大幅减少您的运维工作量,更专注于业务发展,让企业一站式享受数据上云及分布式架构的技术红利!
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档