openldap 安装

1  安装Berkeley DB
# tar zxvf db-4.8.26.tar.gz
# cd db-4.8.26/build_unix/
# ../dist/configure
# make
# make install

# vi /etc/ld.so.conf
加入
/usr/local/BerkeleyDB.4.8/lib
# /sbin/ldconfig

2  安装openldap-stable-20100219.tgz

# tar zxvf openldap-stable-20100219.tgz
# cd openldap-2.4.21/
# env CPPFLAGS="-I/usr/local/BerkeleyDB.4.8/include"  LDFLAGS="-L/usr/local/BerkeleyDB.4.8/lib" ./configure --prefix=/usr/local/openldap --enable-bdb

# make depend
# make
# make test
# make install

vi /usr/local/openldap/etc/openldap/slapd.conf

在include         /usr/local/openldap/etc/openldap/schema/core.schema下面加入以下内容
include         /usr/local/openldap/etc/openldap/schema/corba.schema
include         /usr/local/openldap/etc/openldap/schema/cosine.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

 

suffix          "dc=donnie,dc=com"
rootdn        "cn=root,dc=donnie,dc=com"
rootpw        {SSHA}YBW53fU7sd3wshdPHOWoA7x0EnJrFuRY


{SSHA}YBW53fU7sd3wshdPHOWoA7x0EnJrFuRY这个字符串的取得方法
# /usr/local/openldap/sbin/slappasswd   回车,再输入你用的密码

启动openldap
# /usr/local/openldap/libexec/slapd

建立DN
# ldapadd -x -D 'cn=root,dc=donnie,dc=com' -W
dn: dc=donnie,dc=com
objectClass: dcObject
objectClass: organization
dc: donnie
o: Corporation
description: d Corporation

注:冒号后要有空格,结尾不要有空格
输入完后按Ctrl+d结束

安装phpldapadmin(1.0.1)说明beta 1.1.0-alpha3 版的我装后报错,所以用这个老一点的版本

下载地址:[url]http://prdownloads.sourceforge.net/phpldapadmin/phpldapadmin-1.0.1.tar.gz?download[/url]

# tar zxvf phpldapadmin-1.0.1.tar.gz
# cp -a phpldapadmin-1.0.1 /usr/local/phpldapadmin
# cd ../phpldapadmin/config
# cp config.php.example config.php

# vi config.php

把274行的注释符/*放到282行后,等同于使下在的代码生效
$i++;
$ldapservers->SetValue($i,'server','name','LDAP Server');
$ldapservers->SetValue($i,'server','host','127.0.0.1');
$ldapservers->SetValue($i,'server','port','389');
$ldapservers->SetValue($i,'server','base',array(''));
$ldapservers->SetValue($i,'server','auth_type','cookie');
$ldapservers->SetValue($i,'login','dn','');
$ldapservers->SetValue($i,'login','pass','');

把phpldapadmin变成中文
# cd /usr/local/phpldapadmin/locale/zh_CN/LC_MESSAGES
# iconv -f gbk -t utf8 messages.po > messages.new.po
# msgfmt -o messages.mo messages.new.po

# vi /usr/local/phpldapadmin/htdocs/header.php
$language = isset($config) ? $language = $config->GetValue('appearance','language') : 'zh_CN'; 原auto

重启apache
# /usr/local/apache2/bin/apachectl stop
# /usr/local/apache2/bin/apachectl start