openldap 编译安装

遇到的坑

README 里面有一句:

SLAPD:
    BDB and HDB backends require Oracle Berkeley DB 4.4 - 4.8,
or 5.0 - 5.1.  It is highly recommended to apply the
    patches from Oracle for a given release.

刚开始下载了

wget http://download.oracle.com/berkeley-db/db-6.2.32.tar.gz  //这里在oracle页面上找到版本号wget下载,可以跳过注册账号的步骤

结果报错:

configure: error: BDB/HDB: BerkeleyDB not available

配置库路径:

CPPFLAGS="-I/usr/local/berkeley-db/include/" \
LDFLAGS="-L/usr/local/berkeley-db/lib" \
LD_LIBRARY_PATH="/usr/local/berkeley-db/lib" \
./configure  --prefix=/usr/local/openldap

报错:

configure: error: C compiler cannot create executables

所以正确的步骤:

编译安装 berkeley-db:

wget http://download.oracle.com/berkeley-db/db-5.1.29.tar.gz
tar -xzvf db-5.1.29.tar.gz
cd db-5.1.29/build_unix
../dist/configure --prefix=/usr/local/berkeley-db
make -j4
make install

获取 openldap:

http://www.openldap.org/software/download/

编译安装:

CPPFLAGS="-I/usr/local/berkeley-db/include/" \
LDFLAGS="-L/usr/local/berkeley-db/lib" \
LD_LIBRARY_PATH="/usr/local/berkeley-db/lib" \
./configure  --prefix=/usr/local/openldap
	
make depend 
make
make install

添加schema:
vim /usr/local/openldap/etc/openldap/slapd.conf
include /usr/local/openldap/etc/openldap/schema/corba.schema
include /usr/local/openldap/etc/openldap/schema/core.schema
include /usr/local/openldap/etc/openldap/schema/cosine.schema
include /usr/local/openldap/etc/openldap/schema/duaconf.schema
include /usr/local/openldap/etc/openldap/schema/dyngroup.schema
include /usr/local/openldap/etc/openldap/schema/inetorgperson.schema
include /usr/local/openldap/etc/openldap/schema/java.schema
include /usr/local/openldap/etc/openldap/schema/misc.schema
include /usr/local/openldap/etc/openldap/schema/nis.schema
include /usr/local/openldap/etc/openldap/schema/openldap.schema
include /usr/local/openldap/etc/openldap/schema/ppolicy.schema
include /usr/local/openldap/etc/openldap/schema/collective.schema

编辑文件:

vim /etc/ld.so.conf
/usr/local/berkeley-db/lib/	
ldconfig -v	

启动:

/usr/local/openldap/libexec/slapd

前台启动:

/usr/local/openldap/libexec/slapd -d 256

导入树:

ldapadd -x -D "cn=Manager,dc=wangxiuwen,dc=com" -w password -f setup.ldif
adding new entry "dc=wangxiuwen,dc=cn"

setup.ldif:

dn: dc=wangxiuwen,dc=com
ou: wangxiuwen.com
objectClass: dcObject
objectClass: organizationalUnit
dc: wangxiuwen

dn: ou=people,dc=wangxiuwen,dc=com
ou: people
objectClass: organizationalUnit

dn: ou=groups,dc=wangxiuwen,dc=com
ou: groups
objectClass: organizationalUnit

dn: cn=devops,ou=groups,dc=wangxiuwen,dc=com
description:: 6L+Q57u0
cn: devops
objectClass: posixGroup
objectClass: top
gidNumber: 501
memberUid: sync

客户端:
mac:

http://www.ldapbrowsermac.com/

windows:

http://www.ldapadmin.org/download/ldapadmin.html

参考资料:
http://www.openldap.org/doc/admin22/quickstart.html