#
# 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/cosine.schema
include         /usr/local/openldap/etc/openldap/schema/inetorgperson.schema
include         /usr/local/openldap/etc/openldap/schema/nis.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

# Load dynamic backend modules:
modulepath	/usr/local/openldap/libexec/openldap
moduleload	back_mdb.la
# moduleload	back_ldap.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
#
# 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!

#######################################################################
# config database definitions
#######################################################################
database config
# Uncomment the rootpw line to allow binding as the cn=config
# rootdn so that temporary modifications to the configuration can be made
# while slapd is running. They will not persist across a restart.
# rootpw secret

#######################################################################
# MDB database definitions
#######################################################################

#database	mdb
#maxsize		1073741824
#suffix		"dc=my-domain,dc=com"
#rootdn		"cn=Manager,dc=my-domain,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		secret
# The database directory MUST exist prior to running slapd AND 
# should only be accessible by the slapd and slap tools.
# Mode 700 recommended.
# -----------------------
# OpenLDAP database for sbmplc.com
# -----------------------
database        mdb
# 最大 DB 大小（1GiB），根据需要调整
maxsize         1073741824

# 数据目录：请确保目录存在且 slapd 用户可写
directory       /usr/local/openldap/var/openldap-data

# 命名上下文（域）
suffix          "dc=sbmplc,dc=com"

# 管理员 DN 与密码（替换 rootpw 为 slappasswd 生成的哈希）
rootdn          "cn=admin,dc=sbmplc,dc=com"
rootpw          {SSHA}XiMfWk7m6QxXID50bOvaAAi+PWhc3ajE

# 索引：常用属性及匹配类型（eq, sub, approx, pres）
# 根据你查询习惯调整；缺少索引会导致全表扫描，性能差
index   objectClass                     eq
index   ou,cn,uid,mail,sn                eq,sub,approx
index   uidNumber,gidNumber             eq
index   member,memberUid                 eq
index   description,displayName         sub,eq

# Access Control (基础建议)：
# 1) userPassword 只有自身写、anonymous 认证权限、管理员写，其他不可见
access to attrs=userPassword
    by self write
    by anonymous auth
    by dn="cn=admin,dc=sbmplc,dc=com" write
    by * none

# 2) root DSE（根条目）对所有人可读（便于客户端发现命名上下文）
access to dn.base=""
    by * read

# 3) 默认条目访问策略：本人可写、admin 可写、其他用户只读
access to *
    by self write
    by dn="cn=admin,dc=sbmplc,dc=com" write
    by * read

# （可选）如果你启用了动态模块并装载了 memberOf / syncprov 等模块，可以在这里开启 overlay
# 仅当相应模块可用时才启用，未安装模块会导致启动报错
moduleload memberof
overlay memberof
moduleload syncprov
overlay syncprov
syncprov-checkpoint 100 10
syncprov-sessionlog 100

#directory	/usr/local/openldap/var/openldap-data
# Indices to maintain
#index	objectClass	eq

#######################################################################
# monitor database definitions
#######################################################################
database monitor
