###################################################################################### ##############################################
########## slapd.conf
###################################################################################### ##############################################
#
# See slapd.conf(5) for details on configuration options.
# This file should NOT be world readable.
#
ucdata-path D:/ServerGroup/openldap2.2.19/ucdata
#本句中的core.schema是LDAP V3中必须的,它给出了LDAP V3中最基本的attribute和objects的定义。
#其它的还有:corba.schema、dyngroup.schema、java.schema nis.schema、openldap.schema、cosine.schema、
#inetorgperson.schema、misc.schema、ppolicy.schema
include D:/ServerGroup/openldap2.2.19/etc/schema/core.schema
include D:/ServerGroup/openldap2.2.19/etc/schema/corba.schema
include D:/ServerGroup/openldap2.2.19/etc/schema/cosine.schema
include D:/ServerGroup/openldap2.2.19/etc/schema/dyngroup.schema
include D:/ServerGroup/openldap2.2.19/etc/schema/inetorgperson.schema
include D:/ServerGroup/openldap2.2.19/etc/schema/java.schema
include D:/ServerGroup/openldap2.2.19/etc/schema/misc.schema
include D:/ServerGroup/openldap2.2.19/etc/schema/nis.schema
include D:/ServerGroup/openldap2.2.19/etc/schema/openldap.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://https://www.wendangku.net/doc/694598780.html,
#此句用来定义slapd进程运行时的pid文件,需要使用绝对路径。
pidfile D:/ServerGroup/openldap2.2.19/var/run/slapd.pid
#此句用来定义包含当前正在运行的slapd进程所用到的命令行参数的文件,需要使用绝对路径。argsfile D:/ServerGroup/openldap2.2.19/var/run/slapd.args
# Load dynamic backend modules:
#以上用来指定动态加载的后端模块。
# modulepath D:/ServerGroup/openldap2.2.19/libexec/openldap
# moduleload back_https://www.wendangku.net/doc/694598780.html,
# moduleload back_https://www.wendangku.net/doc/694598780.html,
# moduleload back_https://www.wendangku.net/doc/694598780.html,
# moduleload back_https://www.wendangku.net/doc/694598780.html,
# moduleload back_https://www.wendangku.net/doc/694598780.html,
# Sample security restrictions
#以上是安全相关的声明语句。常用到的参数有五类,除了Require和security外还有Allow、Disallow和password-hash等。
#Require参数用来使管理员指定访问目录时必须遵循的规则和条件;这种指定可以是全局的,也可
以仅用来限制对某个后端数据库的访问限制。
#security参数用来让管理员指定加强安全性的一般规则。
# 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
#
# 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!
#######################################################################
# BDB database definitions
#######################################################################
#定义使用的后端数据存储方式。其后可以跟的值有bdb、ldbm、passwd和shell。bdb指使用Berkley DB 4数据库。
database bdb
suffix "dc=feitian,dc=com"
#定义此目录的超级管理员帐号,类同于系统中的root。由于访问控制对此用户是不生效的,因此存在很大的安全隐患。建议安装配置及调试完成以后移除此帐号。
rootdn "cn=Manager,dc=feitian,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.
#定义超级管理员帐号的密码,这里使用的是明文存储(secret即是其密码)的方式。这是极不安全的,建议使用加密方式存储,
#可以使用的加密方式有:CRYPT、MD5、SMD5、SHA和SSHA。
#产生加密密码散列的方法是使用slappasswd命令,用-h选项指明加密时使用的方式。示例如下:# /usr/local/openldap/sbin/slappasswd -h {SSHA}
#New password:
#Re-enter new password:
#{SSHA}k2H1GPM/95VfgsKg2jZv9hV+2GCH04hC
rootpw secret
# The database directory MUST exist prior to running slapd AND
# should only be accessible by the slapd and slap tools.
# Mode 700 recommended.
#这一句用来指定目录相关数据的存放位置。此目录最好只能由运行slapd进程的用户所有,推荐权限为700
directory D:/ServerGroup/openldap2.2.19/var/openldap-data
# Indices to maintain
#此句用来指定slapd索引时用到的attribute,
#eq指索引时的匹配规则。主要是用来优化查询的。
# index {
#常用到的匹配规则有: approx(模糊匹配,approximate)、eq(精确匹配,equality)、
# pres(现值匹配,若某记录的此attribute没有值则不进行匹配,presence), sub (子串
匹配,substring)。
# For example, to index the cn, sn, uid and objectclass attributes, the following index directives could be used:
#
# index cn,sn,uid pres,eq,approx,sub
# index objectClass eq
index objectClass eq
#启用日志功能,需要在编译时指定--enable-debug 选项,默认是允许的。要打开slapd的日志功能,需要在slapd.conf中的全局配置段添加loglevel指令,并后跟一个十进制数字表示的日志级别,
# 如下所示:
# loglevel 256
# 其日志级别如下所示:
# -1 记录所有的信息
# 0 不记录debug
# 1 跟踪功能调用的信息
# 2 包处理的debug信息
# 4 丰富的debug信息
# 8 连接管理信息
# 16 包的收发信息
# 32 搜索过滤的处理过程
# 64 配置文件的处理过程
# 128 访问控制列表处理过程
# 256 连接、操作及其结果的统计数据
# 512 向客户端返回的结果的统计信息
# 1024 与shell后端的通信信息
# 2048 显示记录条目的分析信息
# 4096 数据库缓存处理信息
# 8192 数据库索引
# 16384 从服务器数据同步资源消耗处理信息
#
#若要记录所有的debug日志,可以使用LOG_LEVEL4 syslogd系统日志来记录,这需要在slapd.conf
中添加如下语句实现:
# local4.debug /var/log/slapd.log
#Added logging parameters
loglevel 256
# 为BDB后端数据库实例指定在内存中的缓存空间大小
# 在如下句子: DBDirectory: /usr/local/openldap/var/openldap-data
# 后添加: DBCachesize: 2000
##高级配置
# 访问控制列表:
1.1 语法
access to
其中,access to指示启用访问控制,上句大致可以理解为:
access to <对什么目标进行控制>[by <作用于哪些访问者> <授予什么样的访问权限><采取什么样的匹配控制动作>]+
1.2 剖析
1.2.1 控制目标
这一域主要是实现对ACL应用对象的指定,对象可以是记录和属性。选择ACL目标记录的方法一般有两种:DN和filter,语法为:
[dn[.
[filter=
1.2.1.1 指定所有的记录
access to *
1.2.1.2 通过DN指定
语法如下:
to dn[.
to dn.
第一种方法是使用正则表达式(dn.regex)或精确匹配(dn.style)的方式来匹配符合条件的记录(这个好像不像想象的那么简单,实现起来颇为费脑筋),例如:
access to dn="^.*,uid=([^,]+),ou=users,(.*)$"
第二种方法通过“区域”选择的方法进行目标记录的选取,对以指定的DN开始的目录树区域进行目标记录匹配。匹配区域的方式共有四种:
base 只匹配DN本身一条记录
one 匹配以给定DN为父目录的所有记录
subtree 匹配以给定DN为根目录的所有子树内的记录
children 匹配给定DN下的所有记录,但应该不包括以DN直接命名的那条记录(参见例子的解释)
例如:对于
0: dc=mydomain,dc=org
1: cn=root,dc=mydomain,dc=org
2: ou=users,dc=mydomain,dc=org
3: uid=samba,ou=users,dc=mydomain,dc=org
4: cn=Administator,uid=samba,ou=users,dc=mydomain,dc=org
5: uid=guest,ou=users,dc=mydomain,dc=org
规则 dn.base="ou=users,dc=mydomain,dc=org" 只会匹配记录2
规则 dn.one="ou=users,dc=mydomain,dc=org" 匹配记录3和记录5,记录4是记录3的子目录,故不算在内
规则 dn.subtree="ou=users,dc=mydomain,dc=org" 匹配记录2、3、4、5
规则 dn.children="ou=users,dc=mydomain,dc=org" 匹配记录3、4、5,因为记录0、1和2都是以DN 直接命名的,故不匹配
1.2.1.3 通过filter匹配记录
通过filter指定过滤规则进行记录过虑,语法如下:
access to filter=
其中filter指定的为search的过滤规则,这类同于linux系统中grep的匹配方式。如:
access to filter=(objectClass=sambaSamAccount)
也可以结合使用DN和filter进行记录的匹配,例如:
access to dn.subtree="ou=users,dc=mydomain,dc=org" filter=(objectClass=posixAccount)
1.2.1.4 通过attrs选取匹配记录
语法:
attrs=
例如:
access to attrs=uid,uidNumber,gidNumber
也可以结合使用DN和attrs进行记录的匹配,例如:
access to dn.subtree="ou=users,dc=mydomain,dc=org" attrs=uid
1.2.2 被用来授权的访问者
指定被授权的用户范围的方法大致有以下几种:
* 所有的访问者,包括匿名的用户
anonymous 非认证的匿名用户
users 认证的用户
self 目标记录的用户自身
dn[.
dn.
例如:
by dn.subtree="ou=users,dc=domain,dc=org"="^samba*"
1.2.3 被授予的权限
当选取好ACL作用的目标记录并选取好用户范围后,就该给这些用户授予他们应该得到的权限了。
大致的权限(由低到高)有以下几类:
none 无权限,即拒绝访问
auth 访问bind(认证)设置的权限;前提是需要用户提交一个DN形式的用户名并能通过认证compare 比较属性的权限;(例如:对照查看某用户的telephoneNumber值是不是158 **** ****),但并不具有搜索的权限
search 利用过虑条件进行搜索的权限,但这并不一定具有可读取搜索结果的权限
read 读取搜索结果的权限
write 更改记录属性值的权限
可以在slapd.conf文件中通过defaultaccess指定默认的权限级别,如:
defaultaccess search
1.2.4 采取什么样的匹配控制动作
在进行记录的匹配时,如果有多条规则存在,那么在第一次匹配产生后是否还进行后续的匹配或采
取其它的动作将取决于此项的设置;控制方式共有以下三种:
stop 这个是默认值,这表示在一次匹配产生后将不再进行下一个匹配,所有后续的匹配将会停止。continue 无论匹配是否已经发生,继续进行直到所有的规则全部进行完匹配检查
break 一个匹配发生后,跳出当前的子句进行后一个子句的检查
1.2.5 一个例子
access to dn.chilren="ou=users,dc=mydomain,dc=org"
attrs=userPassword #指定“密码”属性
by self write #用户自己可更改
by * auth #所有访问者需要通过认证
by dn.children="ou=admins,dc=mydomain,dc=org" write #管理员组的用户可更改
######################################################################################
##############################################
########## Edit lidf file
######################################################################################
##############################################
#Notice: ldif文件中,每一行中冒号后有一个空格,行尾一定不能有空格。切记!
# ldapadd -x -D "cn=Manager,dc=feitian,dc=com" -W -f imq.ldif # ldapsearch -x -b 'dc=feitian,dc=com' '(objectclass=*)'
dn: o=HR,dc=feitian,dc=com
objectclass: organization
objectclass: top
o: HR
dn: ou=R&D,o=HR,dc=feitian,dc=com
objectclass: organizationalUnit
objectclass: top
ou: R&D
#定义人员1
dn: cn=Tom Black,ou=R&D,o=HR,dc=feitian,dc=com
cn: Tom Black
sn: Black
mail: tom@https://www.wendangku.net/doc/694598780.html,
telephoneNumber: 371-6338-3522
objectClass: inetOrgPerson
#定义人员2
dn: cn=Jerry Smith,ou=R&D,o=HR,dc=feitian,dc=com
cn: Jerry Smith
sn: Smith
mail: jerry@https://www.wendangku.net/doc/694598780.html,
telephoneNumber: 371-6338-3521
objectClass: inetOrgPerson