一、安装openldap的数据库,Berkeley DB
下载地址:
Download (HTTP): http://download.oracle.com/berkeley-db/db-5.3.21.tar.gz
tar zxvf db-4.6.21.tar.gz
cd db_4.6.21/build_unix/
../dist/configure
sudo make
sudo make install
拷贝库文件:
sudo cp /usr/local/BerkeleyDB.4.6/include/* /usr/include/
sudo cp /usr/local/BerkeleyDB.4.6/lib/* /usr/lib/
二、安装openldap:
解压发行包:
gunzip -c openldap-2.4.19.tgz | tar xvfB -
cd openldap-2.4.19/
添加环境变量:
env CPPFLAGS="-I/usr/local/BerkeleyDB.4.6/include"
LDFLAGS="-L/usr/local/BerkeleyDB.4.6/lib" ./configure --prefix=/usr/local/openldap --enable-ldbm
编译软件
sudo make depend
sudo make
测试编译
sudo make test
安装软件
su make install
到此安装完成
三、配置openldap
OpenLDAP 的主配置文件是/usr/local/openldap/etc/openldap/slapd.conf
,需要注意的是,每次修改配置文件的设置后,都要重新起动OpenLDAP服务,这样才能使配置生效。
1设置LDAP使用的schema
sudo gedit /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
1.2设置目录树的后缀
suffix "dc=my-domain,dc=com"
改为:
suffix "dc=miracle,dc=com"
1.3设置管理员的DN
rootdn "cn=Manager,dc=my-domain,dc=com"
改为:
rootdn "cn=admin(设置管理员),dc=open(设置域名),dc=com"
1.4设置管理员口令
rootpw secret(这是密码位置)
改为:
root pw {SSHA}e7BBqjes5EF1grsupjvUfNkNdmZD+F6u
该结果是明文“miracle”经SSHA加密运算后的结果,生成加密密码方法:
miracle@miracle-desktop:~$ sudo /usr/local/openldap/sbin/slappasswd
[sudo] password for miracle:
New password:
Re-enter new password:
{SSHA}e7BBqjes5EF1grsupjvUfNkNdmZD+F6u
四、常用命令:
测试启动
sudo /usr/local/openldap/libexec/slapd -d 256 & (-d用来指定调试信息输出级别)
启动服务
sudo /usr/local/openldap/libexec/slapd
查看端口
pstree|grep "slapd"
查看监听的端口
netstat -tnlp |grep :389
导入域帐号(如何编辑请继续看):
/usr/local/openldap/bin/ldapadd -x -D "cn=admin(你的管理员),dc=open(你的域名),dc=com" -W -f test.ldif(你的ldif文件)
关闭openldap
sudo kill -INT `cat /usr/local/openldap/var/run/slapd.pid`
五、编辑ldif文件
建立DN
gedit dn.ldif
- dn: dc=open,dc=com
- objectClass: dcObject
- objectClass: organization
- dc: it
- o: Corporation
- description: d Corporation
dn: uid=qq,dc=open,dc=com objectClass: person objectClass: organizationalPerson objectClass: inetOrgPerson uid: qq cn: qq sn: qq userPassword:123456 telephoneNumber: 138888888 description: openldap test telexNumber: tex-8888888 street: my street postOfficeBox: postofficebox displayName: qqdisplay homePhone: home1111111 mobile: mobile99999 mail:[email protected]