Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1458282
  • 博文数量: 408
  • 博客积分: 10036
  • 博客等级: 上将
  • 技术积分: 4440
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-06 13:57
文章分类

全部博文(408)

文章存档

2011年(1)

2010年(2)

2009年(1)

2008年(3)

2007年(7)

2006年(394)

我的朋友

分类: LINUX

2006-06-19 18:29:38

 
Web me09.cublog.cn
搜索更多openldap的详细配置

[ 作者:  加入时间:2005-12-02 09:38:57  来自: ]



我刚刚配完openldap具体如下:
安装软件包需要注意的问题
编译
编译和优化
清除不必要的文件

配置
配置“/etc/ldap/slapd.conf”文件
配置“/etc/rc.d/init.d/ldap”脚本文件
更多的资料

保证OpenLDAP的安全
使得重要的配置文件不可改变

OpenLDAP的创建和维护工具
离线创建数据库
IDIF输入文件(用文本表示的输入文件)
为LDAP创建数据库
ldapmodify

OpenLDAP的用户工具
搜索LDAP的数据项

安装到系统中的文件

概述
LDAP(Lightweight Directory Access Protocol)是用来访问信息服务的标准协议。这个协议是用在Internet传输协议上,如:TCP,能够访问单独的目录服务或X.500目录。

注意事项

下面所有的命令都是Unix兼容的命令。
源路径都为“/var/tmp”(当然在实际情况中也可以用其它路径)。
安装在RedHat Linux 6.1下测试通过。
要用“root”用户进行安装。
OpenLDAP的版本号是1_2_8。

软件包的来源
OpenLDAP的主页:。

下载:openldap-1_2_8.tgz。

安装软件包需要注意的问题
最 好在编译前和编译后都做一张系统中所有文件的列表,然后用“diff”命令去比较它们,找出其中的差别并知道到底把软件安装在哪里。只要简单地在编译之前 运行一下命令“find /* >ldap1”,在编译和安装完软件之后运行命令“find /* > ldap2”,最后用命令“diff ldap1 ldap2 > ldap”找出变化。

编译
把软件包(tar.gz)解压缩:

[root@deep]# cp openldap-version.tgz /var/tmp
[root@deep]# cd /var/tmp/
[root@deep]# tar xzpf openldap-version.tgz

编译和优化
转到OpenLDAP的新目录下。

编辑“string.h”文件(vi +52 include/ac/string.h),删掉这些几行:

#else
/* some systems have strdup(), but fail to declare it */
extern char *(strdup)();

上面的这几行对Linux系统是没有用的必须删掉。

下面设置编译器的编译参数:

CC="egcs"
CFLAGS="-O9 -funroll-loops -ffast-math -malign-double -mcpu=pentiumpro -march=pentiumpro -fomit-frame-
pointer -fno-exceptions"
./configure
--prefix=/usr
--libexecdir=/usr/sbin
--localstatedir=/var/run
--sysconfdir=/etc
--enable-shared
--with-gnu-ld

这些编译参数告诉编译器如何编译OpenLDAP:

l 编译共享库
l 假定C编译器使用GNU ld

开始编译:

[root@deep]# make depend
[root@deep]# make
[root@deep]# cd tests/
[root@deep]# make
[root@deep]# cd ..
[root@deep]# make install

“make depend”命令编译必要的相关文件,“make”把源文件编译成可执行的二进制文件。“make install”把二进制文件和相关的配置文件安装到相应的目录中去。在“test”目录下的“make”命令在安装LDAP服务器之前进行一些必要的测 试保证软件安装完成后能正常运行。如何测试失败在继续安装之前先要解决这些问题。

[root@deep]# install -d -m 700 /var/ldap
[root@deep]# echo localhost > /etc/openldap/ldapserver
[root@deep]# strip /usr/lib/liblber.so.1.0.0
[root@deep]# strip /usr/lib/libldap.so.1.0.0
[root@deep]# strip /usr/lib/libldap.a
[root@deep]# strip /usr/lib/liblber.a
[root@deep]# strip /usr/sbin/in.xfingerd
[root@deep]# strip /usr/sbin/go500
[root@deep]# strip /usr/sbin/go500gw
[root@deep]# strip /usr/sbin/mail500
[root@deep]# strip /usr/sbin/rp500
[root@deep]# strip /usr/sbin/fax500
[root@deep]# strip /usr/sbin/rcpt500
[root@deep]# strip /usr/sbin/slapd
[root@deep]# strip /usr/sbin/ldif2ldbm
[root@deep]# strip /usr/sbin/ldif2index
[root@deep]# strip /usr/sbin/ldif2id2entry
[root@deep]# strip /usr/sbin/ldif2id2children
[root@deep]# strip /usr/sbin/ldbmcat
[root@deep]# strip /usr/sbin/ldif
[root@deep]# strip /usr/sbin/centipede
[root@deep]# strip /usr/sbin/ldbmtest
[root@deep]# strip /usr/sbin/slurpd
[root@deep]# strip /usr/bin/ud
[root@deep]# strip /usr/bin/ldapadd
[root@deep]# strip /usr/bin/ldapsearch
[root@deep]# strip /usr/bin/ldapmodify
[root@deep]# strip /usr/bin/ldapmodrdn
[root@deep]# strip /usr/bin/ldappasswd
[root@deep]# strip /usr/bin/ldapdelete

上面的“install”命令在“/var”目录下创建一个名为“ldap”的新目录并且把它的属性设成只能被超级用户“root”读、写和执行。

“strip”命令清除目标文件中所有的符号信息,这样可执行文件就会更小,能够提高一点程序的性能。

清除不必要的文件
用下面的命令删除不必要的文件:

[root@deep]# cd /var/tmp
[root@deep]# rm -rf ldap openldap-version.tgz

“rm”命令删除所有编译和安装OpenLDAP所需要的源程序,并且把“/var/tmp”目录下的OpenLDAP软件的压缩包删除掉。

配置
可 以到这去下载“floppy.tgz”文件:http: //pages.infinit.net/lotus1/doc/opti/floppy.tgz。把“floppy.tgz”文件解开之后,可以在相应 的目录下发现我们在这本书中介绍的所有软件的配置文件。这样就没有必要手工重新生成这些文件,或者用拷贝粘贴的方法把它们粘贴到配置文件中去。不管是打算 自己动手生成配置文件还是拷贝现成的,你都要学会自己修改配置文件并且把配置文件拷贝到正确的目录下。下面将具体说明。

为了运行OpenLDAP,必须创建或者把下面的文件拷贝到相应的目录下:

l 把“slapd.conf”文件拷贝到“/etc/openldap”目录下
l 把“ldap”文件拷贝到“/etc/rc.d/init.d”目录下

可以把“floppy.tgz”解压之后,找到上面列出来的文件,并拷贝到“/etc/ssh”目录下,或者用拷贝粘贴的方法从本书中直接粘贴出。

配置“/etc/ldap/slapd.conf”文件
“/etc/openldap/slapd.conf”文件是LDAP服务器最重要的配置文件,配置权限、口令、数据库类型和数据库位置等等。

编辑“slap.conf”文件(vi /etc/openldap/slapd.conf)加入:

#
# See slapd.conf(5) for details on configuration options.
# This file should NOT be world readable.
#
include /etc/openldap/slapd.at.conf
include /etc/openldap/slapd.oc.conf
schemacheck off
#referral
pidfile /var/run/slapd.pid
argsfile /var/run/slapd.args
#######################################################################
# ldbm database definitions
#######################################################################
database ldbm
suffix "o=openarch, c=com"
directory /var/ldap
rootdn "cn=admin, o=openarch, c=com"
rootpw secret
# cleartext passwords, especially for the rootdn, should
# be avoid. See slapd.conf(5) for details.
# ldbm indexed attribute definitions
index cn,sn,uid
index objectclass pres,eq
index default none
# ldbm access control definitions
defaultaccess read
access to attr=userpassword
by self write
by dn="cn=admin, o=openarch, c=com" write
by * compare

下面解释一下上面配置文件中的一些设置:

suffix “o=openarch, c=com”

suffix(后缀)设置想要创建的子树的根的DN(distinguished name)。换句话说,就是表示数据库中到底放些什么。

directory /var/ldap

设置LDAP数据库和索引文件所在的目录。必须设置为“/var/ldap”因为我们在安装阶段已经指定了LDAP的后台数据库。

rootdn “cn=admin, o=openarch, c=com”

设置管理LDAP目录的超级用户的DN。这个用户名(admin)并不要出现在“/etc/passwd”文件里。

rootpw secret

设置这个数据库的超级用户的口令验证方式。也就是上面“rootdn”设置的用户的口令。千万不要用明文进行口令验证,一定要用加密的口令。

index cn,sn,uid | index objectclass pres,eq | index default none

这 三句设置在数据库中创建和维护怎样的索引。“index cn,sn,uid)为cn、sn和uid属性创建和维护索引,“index objectclass pres,eq”为objectclass属性创建相等索引(equality indexes),“index default none”表示不为别的属性创建索引。查看用户手册可以得到更多的信息。

“slapd.conf”文件中的最后一部分是和LDAP目录的访问控制相关的。

defaultaccess read
access to attr=userpassword
by self write
by dn="cn=admin, o=openarch, c=com" write
by * compare

这 些设置对“o=openarch,c=com”子树中的所有项都是有效的。任何人都有读的权限,除了“userpasswd”属性拥有这一项的用户可以改 变其它所有的属性。“userpassword”属性只能被admin修改,但是任何人都可以比较。查看用户手册可以得到更多的信息。

配置“/etc/rc.d/init.d/ldap”脚本文件
配置“/etc/rc.d/init.d/ldap”脚本文件用来启动和停止ldap服务。

创建“ldap”脚本文件(touch /etc/rc.d/init.d/ldap)并加入:

#!/bin/sh
#
# ldap This shell script takes care of starting and stopping
# ldap servers (slapd and slurpd).
#
# chkconfig: - 70 40
# description: LDAP stands for Lightweight Directory Access Protocol, used
# for implementing the industry standard directory services.
# processname: slapd
# config: /etc/openldap/slapd.conf
# pidfile: /var/run/slapd.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -f /usr/sbin/slapd ] || exit 0
[ -f /usr/sbin/slurpd ] || exit 0
RETVAL=0
# See how we were called.
case "$1" in
start)
# Start daemons.
echo -n "Starting ldap: "
daemon slapd
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
if grep -q "^replogfile" /etc/openldap/slapd.conf; then
daemon slurpd
RETVAL=$?
[ $RETVAL -eq 0 ] && pidof slurpd | cut -f 1 -d " " > /var/run/slurpd
fi
fi
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ldap
;;
stop)
# Stop daemons.
echo -n "Shutting down ldap: "
killproc slapd
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
if grep -q "^replogfile" /etc/openldap/slapd.conf; then
killproc slurpd
RETVAL=$?
fi
fi
echo
if [ $RETVAL -eq 0 ]; then
rm -f /var/lock/subsys/ldap
rm -f /var/run/slapd.args
fi
;;
status)
status slapd
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
if grep -q "^replogfile" /etc/openldap/slapd.conf; then
status slurpd
RETVAL=$?
fi
fi
;;
restart)
$0 stop
$0 start
RETVAL=$?
;;
reload)
killproc -HUP slapd
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
if grep -q "^replogfile" /etc/openldap/slapd.收集整理



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