最近研究起了ldap,使用的服务端是linux下面的openldap.
首先先到openldap的官方网站http://www.openldap.org/下载最新版本.
其次下载BerkeleyDB,我用的版本要是默认安装的话必须要先安装BerkeleyDB数据库.
接着linux安装三步骤:configure make make install
注:安装ldap最好使用env CPPFLAGS="-I/usr/local/BerkeleyDB.4.2/include" LDFLAGS="-L/usr/local/BerkeleyDB.4.2/lib" ./configure --prefix=/usr/local/openldap --enable-ldbm 语句添加指定的数据库,避免安装报找不到之类的错误.
接着make depens 然后make 再make test 最后 make install.注:时间是要花去不少的,
接下来配置slapd.conf下面是一个配置例子(路径可能要修改):
## See slapd.conf(5) for details on configuration options.# This file should NOT be world readable.#include /usr/local/openldap/etc/openldap/schema/core.schemainclude /usr/local/openldap/etc/openldap/schema/corba.schemainclude /usr/local/openldap/etc/openldap/schema/cosine.schemainclude /usr/local/openldap/etc/openldap/schema/inetorgperson.schemainclude /usr/local/openldap/etc/openldap/schema/misc.schemainclude /usr/local/openldap/etc/openldap/schema/openldap.schemainclude /usr/local/openldap/etc/openldap/schema/nis.schema#include /usr/local/openldap/etc/openldap/schema/samba.schema# Define global ACLs to disable default read access.
# Do not enable referrals until AFTER you have a working directory# service AND an understanding of referrals.#referral ldap://root.openldap.org
pidfile /usr/local/openldap/var/run/slapd.pidargsfile /usr/local/openldap/var/run/slapd.args
#loglevel 1# Load dynamic backend modules:# modulepath /usr/local/openldap/libexec/openldap# moduleload back_bdb.la# moduleload back_ldap.la# moduleload back_ldbm.la# moduleload back_passwd.la# moduleload back_shell.la
# Sample security restrictions# Require integrity protection (prevent hijacking)# Require 112-bit (3DES or better) encryption for updates# Require 63-bit encryption for simple bind# security ssf=1 update_ssf=112 simple_bind=64
# Sample access control policy:# Root DSE: allow anyone to read it# Subschema (sub)entry DSE: allow anyone to read it# Other DSEs:# Allow self write access# Allow authenticated users read access# Allow anonymous users to authenticate# Directives needed to implement policy:# access to dn.base="" by * read# access to dn.base="cn=Subschema" by * read# access to *# by self write# by users read# by anonymous authaccess to attr=userPassword by self write by anonymous authaccess to * by self write by * read by anonymous auth ## if no access controls are present, the default policy# allows anyone and everyone to read anything but restricts# updates to rootdn. (e.g., "access to * by * read")## rootdn can always read and write EVERYTHING!
# CA#TLSCipherSuite HIGH#TLSCACertificateFile /usr/local/openldap/ssl/cacert.pem#TLSCertificateFile /usr/local/openldap/ssl/servercrt.pem#TLSCertificateKeyFile /usr/local/openldap/ssl/serverkey.pem
######################################################################## BDB database definitions#######################################################################
database bdb#database ldbmsuffix "dc=wtest,dc=com"rootdn "cn=root,dc=wtest,dc=com"#suffix "dc=wyy,dc=com"#rootdn "cn=root,dc=wyy,dc=com"# Cleartext passwords, especially for the rootdn, should# be avoid. See slappasswd(8) and slapd.conf(5) for details.# Use of strong authentication encouraged.#rootpw weiyyrootpw {MD5}iTY48U9l8D+CeCZ04LRKGw==# The database directory MUST exist prior to running slapd AND # should only be accessible by the slapd and slap tools.# Mode 700 recommended.directory /usr/local/openldap/var/openldap-data# Indices to maintainindex objectClass eq
配置好后在libexec目录下面运行./slapd就可以了,如果没起来 可以用 ./slapd -d 256 查看
我用的是Jini程序来连接操作openldap的.ldapbrowser是一款不错的操作软件.