ldap使用

最近研究起了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.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/inetorgperson.schema
include  /usr/local/openldap/etc/openldap/schema/misc.schema
include  /usr/local/openldap/etc/openldap/schema/openldap.schema
include  /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.pid
argsfile /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 auth
access to attr=userPassword
 by self write
 by anonymous auth
access 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 ldbm
suffix  "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  weiyy
rootpw  {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 maintain
index objectClass eq
 

配置好后在libexec目录下面运行./slapd就可以了,如果没起来 可以用 ./slapd -d 256 查看

我用的是Jini程序来连接操作openldap的.ldapbrowser是一款不错的操作软件.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值