只为留下点什么

   ::  ::  ::  ::  :: 管理
包下载地址

openldap包 ftp://ftp.openldap.org/pub/OpenLDAP/openldap-release/openldap-2.4.49.tgz
所需的BerkeleyDB包(可以看README文件) https://download.oracle.com/berkeley-db/db-4.6.21.tar.gz

安装依赖
yum -y install gcc gcc-c++ libtool libtool-ltdl libtool-ltdl-devel openssl openssl-devel openssl-libs cyrus-sasl cyrus-sasl-devel

编译BerkeleyDB

#不安装的话会报‘peercred’ isn’t known错误
tar xf db-4.6.21.tar.gz
cd db-4.6.21/build_unix/
../dist/configure -prefix=/usr/local/BerkeleyDB

编译openldap

#需要指定CPPFLAGS和LDFLAGS如果编译不过去还需要指定lib库 
#echo "/usr/local/berkeleydb-5.1.29/lib/" > /etc/ld.so.conf
#ldconfig
tar xf openldap-2.4.49.tgz
cd openldap-2.4.49/
./configure --prefix=/openldap CPPFLAGS=-I/usr/local/BerkeleyDB/include/ LDFLAGS=-L/usr/local/BerkeleyDB/lib
#添加环境变量
vim /etc/profile
LDAP_HOME=/openldap
export PATH=$PATH:${LDAP_HOME}/bin:${LDAP_HOME}/sbin:${LDAP_HOME}/libexec

编辑配置文件

#查看schema的加载顺序 将schema目录里面的schema加载到配置文件
vim /openldap/etc/openldap/schema/README
include		/openldap/etc/openldap/schema/core.schema
include 	/openldap/etc/openldap/schema/collective.schema
include 	/openldap/etc/openldap/schema/corba.schema
#include 	/openldap/etc/openldap/schema/core.schema #这里重复了
include 	/openldap/etc/openldap/schema/cosine.schema
include 	/openldap/etc/openldap/schema/duaconf.schema
include 	/openldap/etc/openldap/schema/dyngroup.schema
include 	/openldap/etc/openldap/schema/inetorgperson.schema
include 	/openldap/etc/openldap/schema/java.schema
include 	/openldap/etc/openldap/schema/misc.schema
#include 	/openldap/etc/openldap/schema/nadf.schema #这个schema需要我的需要去掉才能启动
include 	/openldap/etc/openldap/schema/nis.schema
include 	/openldap/etc/openldap/schema/openldap.schema
include 	/openldap/etc/openldap/schema/ppolicy.schema
pidfile		/openldap/var/run/slapd.pid
argsfile	/openldap/var/run/slapd.args
database	mdb
maxsize		1073741824
suffix		"dc=test,dc=com"
rootdn		"cn=admin,dc=test,dc=com"
rootpw		admin #我这里用的是明文可以用slappasswd来加密
directory	/openldap/var/openldap-data
index	objectClass	eq
loglevel 256    #增加log
logfile    /openldap/var/slapd.log #log文件位置


#cd /openldap/var/openldap-data
cp DB_CONFIG.example DB_CONFIG

测试

slapd -u root
ldapsearch -LLL -W -H ldap://ldap.test.com -D "cn=admin,dc=test,dc=com" -b "dc=test,dc=com" "(uid=*)"
ldapsearch -x -b 'dc=test,dc=com' '(objectClass=*)'
posted on 2020-03-21 21:48  只为留下点什么  阅读(588)  评论(0编辑  收藏  举报