Chinaunix首页 | 论坛 | 博客
  • 博客访问: 291680
  • 博文数量: 49
  • 博客积分: 4776
  • 博客等级: 中校
  • 技术积分: 486
  • 用 户 组: 普通用户
  • 注册时间: 2005-03-02 10:42
文章分类

全部博文(49)

文章存档

2010年(6)

2009年(8)

2008年(20)

2007年(10)

2006年(2)

2005年(3)

分类:

2007-10-30 16:10:01

CenTOS 5下面用自带的RPM包安装openLDAP
Author:汪洋
Nickname:ruochen / ruochen0926
Date:20070927
Version:1.0
Contact: E-Mail:yang_wang(at)sae.com.hk  QQ:967409
Blog:http://ruochen.cublog.cn/
Note:如果在安装或者使用过程中有疑问,请到我的blog跟帖,我会尽快回复

目录:
目标:配置一个基本的LDAP系统,并且带有中文web管理界面
1)安装需要的软件包
2)配置openLDAP主配置文件/etc/openldap/slapd.conf
3)安装openLDAP GUI管理客户端
3.1)phpLDAPadmin的安装和配置
3.2)lam (LDAP Account Manager)的安装和配置
4)配置openLDAP支持SASL
4)openLDAP主从复制服务器配置
5)openLDAP双向复制服务器配置
6)FAQ
1)安装需要的软件包
[root@mail pub]# rpm -qa|grep ldap
openldap-2.3.27-5
openldap-servers-2.3.27-5
openldap-clients-2.3.27-5
openldap-devel-2.3.27-5
Openldap-2.0*是必要套件,一定要先安装;
Openldap-servers*是服务器套件;
openldap-clients*是操作程序套件;
openldap-devel*是开发工具套件.
如果需要用ldap做一些高级应用,还需要加装如下套件:
php-ldap-5.1.6-5.el5
python-ldap-2.2.0-2.1
nss_ldap-253-3

下面的包是配置openLDAP的GUI管理界面lam所需要的
mhash-0.9.9-1.el5
php-mhash-5.1.6-12

Apache LDAP认证的模块,根据自己需要来安装

mod_authz_ldap.i386
建议yum安装,自动解决软件包之间的依赖关系
 
2)配置/etc/openldap/slapd.conf
备份原始配置档 (Linux/Unix管理员都应该养成这样的好习惯)
[root@mail openldap]# cp /etc/openldap/slapd.conf /etc/openldap/slapd.conf-orig
配置openldap的主配置文件
[root@mail openldap]# vi /etc/openldap/slapd.conf
include         /etc/openldap/schema/dyngroup.schema
include         /etc/openldap/schema/java.schema
include         /etc/openldap/schema/misc.schema
include         /etc/openldap/schema/openldap.schema
include         /etc/openldap/schema/ppolicy.schema
include         /etc/openldap/schema/corba.schema
database bdb
suffix "dc=example,dc=com"    #一条记录所属区域#
rootdn "cn=admin,dc=example,dc=com"
rootpw 1234567                 #定义LDAP根管理员的密码(强烈建议使用加密的密码)

将系统账户转移到openldap中
[root@mail openldap]# vi /usr/share/openldap/migration/migrate_common.ph
$DEFAULT_MAIL_DOMAIN = "example.com";
Default base
$DEFAULT_BASE = "dc=example,dc=com";

[root@mail openldap]# cd /usr/share/openldap/migration/
[root@mail migration]#  ./migrate_passwd.pl /etc/passwd > /etc/openldap/user.ldif
[root@mail migration]#  ./migrate_group.pl /etc/group > /etc/openldap/group.ldif
建立example.ldif,ou_people.ldif, ou_group.ldif三个文件
[root@mail migration]# cd /etc/openldap/
[root@mail openldap]# cat example.ldif
dn: dc=example,dc=com
dc: example
objectClass: dcObject
objectClass: organizationalUnit
ou: example.com
[root@mail openldap]# cat ou_people.ldif
dn: ou=people, dc=example, dc=com
objectclass: organizationalunit
ou: people
[root@mail openldap]# cat ou_group.ldif
dn: ou=group, dc=example, dc=com
objectclass: organizationalunit
ou: group
停止ldap服务
[root@mail openldap]# service ldap stop

转换原有Linux 账号至OpenLDAP服务器上:
[root@mail openldap]# slapadd -vl example.ldif
added: "dc=example,dc=com" (00000001)
[root@mail openldap]# slapadd -vl ou_people.ldif
added: "ou=people,dc=example,dc=com" (00000002)
[root@mail openldap]# slapadd -vl ou_group.ldif
added: "ou=group,dc=example,dc=com" (00000043)
[root@mail openldap]# slapadd -vl user.ldif
[root@mail openldap]# slapadd -vl group.ldif

配置DB_CONFIG配置文件
[root@mail html]# cp /etc/openldap/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
把/var/lib/ldap/目录内的档案变更拥有者及群组为ldap
[root@mail html]# chown  -R  ldap.ldap /var/lib/ldap
 
为了检查服务是否正在运行并且被正确配置,可以对服务器运行一个搜索命令,使用ldapsearch
ldapsearch -x -b '' -s base '(objectclass=*)' namingContexts;
注意命令行参数中单引号的使用,它们阻止特殊的字符被shell解析。这应该返回:
[root@mail openldap]# service ldap start
[root@mail openldap]# ldapsearch -x -b '' -s base '(objectclass=*)' namingContexts;
# extended LDIF
#
# LDAPv3
# base <> with scope baseObject
# filter: (objectclass=*)
# requesting: namingContexts
#
#
dn:
namingContexts: dc=example,dc=com
# search result
search: 2
result: 0 Success
# numResponses: 2
# numEntries: 1
 
 

3)安装openLDAP GUI管理客户端
3.1)phpLDAPadmin的安装和配置
下载最新版本的phpLDAPadmin
[root@mail openldap]# tar -zvxf phpldapadmin-1.1.0-alpha4.tar.gz
[root@mail openldap]# chown -R apache.apache phpldapadmin-1.1.0-alpha4
[root@mail openldap]# cd phpldapadmin-1.1.0-alpha4/config/
[root@mail config]# cp config.php.example config.php
[root@mail config]# vi config.php
// $config->custom->appearance['language'] = 'auto';
$config->custom->appearance['language'] = 'zh_CN';
 
3.2)lam (LDAP Account Manager)的安装和配置

ldap-account-manager-2.0.0.tar.gz
 
客户端的配置
在客户端执行authconfig-tui命令,进入认证配置界面

4)openLDAP主从复制服务器配置
MasterLDAP: 10.10.119.200
SlaveLDAP: 10.10.119.204
Port:  389
在MasterLDAP端修改openLDAP主配置文件/etc/openldap/slapd.conf
[root@mail openldap]# vi /etc/openldap/slapd.conf
replogfile /var/lib/ldap/openldap-master-replog
replica host=10.10.119.204:389
        suffix="dc=example,dc=com"
        binddn="cn=admin,dc=example,dc=com"
        bindmethod=simple
        credentials=123456

在SlaveLDAP端修改openLDAP主配置文件/etc/openldap/slapd.conf
[root@mail openldap]# vi /etc/openldap/slapd.conf
updatedn        "cn=admin,dc=example,dc=com"
updateref      
5)openLDAP双向复制服务器配置
MasterLDAP: 10.10.119.200
SlaveLDAP: 10.10.119.204
Port:  389
在MasterLDAP端修改openLDAP主配置文件/etc/openldap/slapd.conf
[root@mail openldap]# vi /etc/openldap/slapd.conf
updatedn        "cn=admin,dc=example,dc=com"
updateref      

在SlaveLDAP端修改openLDAP主配置文件/etc/openldap/slapd.conf
[root@mail openldap]# vi /etc/openldap/slapd.conf
replica host=10.10.119.200:389
        suffix="dc=example,dc=com"
        binddn="cn=admin,dc=example,dc=com"
        bindmethod=simple
        credentials=123456

Notes: 我的实现方法应该不是正宗的,是在主从配置的想法上得来的,在网上和openLDAP的官方手册中都没有看到openLDAP双向复制服务器配置的案例,理论上这样配置的ldap服务起会发生“死循环”的问题,还好openLDAP在10.10.119.200:389.rej文件和10.10.119.204:389.rej文件记录了这种循环,而不会导致真正的死循环
6)FAQ
6.1) Q1启动服务时出现/var/lib/ldap/**.dbd owner is not ldap
A1
[root@mail html]# chown  -R  ldap.ldap /var/lib/ldap

6.2)Q2启动服务时出现bdb_db_open: Warning - No DB_CONFIG file found in directory  /var/lib/ldap
Oct 19 10:19:34 ldap slapd[55696]: bdb_db_open: Warning - No DB_CONFIG file found in directory  /var/lib/ldap: (2)
Expect poor performance for suffix dc=admin,dc=example,dc=com.
A2
[root@mail html]# cp /etc/openldap/DB_CONFIG.example /var/lib/ldap/DB_CONFIG

6.3) Q3在做ldapwhoami或者ldapsearch是出现sasl绑定错误
ldap_sasl_interactive_bind_s: Invalid credentials (49)
        additional info: SASL(-13): user not found: no secret in database

A3:
默认的openLDAP是基于 sasl 的绑定,需要先创建sasl用户及其密码
[root@mail html]# saslpasswd2 -c UserName
输入两次密码,密码保存在/etc/sasldb2,可以用 sasldblistusers2 命令查看用户名称
在ldapsearch等命令中使用 -U UserName -W参数,然后输入上面的密码就行
 
 
 

 
阅读(3887) | 评论(2) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2008-12-23 13:42:58

没人帮助楼上的?

chinaunix网友2008-08-28 10:27:53

我刚好碰到问题3,按此方法一试,结果仍然提示: ldap_sasl_interactive_bind_s: Invalid credentials (49) additional info: SASL(-13): user not found: no secret in database 这让我相当郁闷,OpenLDAP就此进行不下去,盼ruochen帮忙解决一下,,百分感谢