1. 修改slapd.conf
vi /etc/openldap/slapd.conf
include /etc/openldap/schema/core.schema
include /etc/openldap/schema/cosine.schema
include /etc/openldap/schema/inetorgperson.schema
include /etc/openldap/schema/misc.schema
include /etc/openldap/schema/nis.schema
database bdb
#BaseDN
suffix "dc=pro,dc=com"
#rootDN
rootdn "cn=admin,dc=pro,dc=com"
rootpw 123456
directory /var/lib/ldap
2.重新生成配置文件
rm -rf /etc/openldap/slapd.d/*
slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d -u
chown -R ldap.ldap /etc/openldap/slapd.d/
cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
chown -R ldap.ldap /var/lib/ldap/
touch /var/run/openldap/slapd.pid
chown ldap.ldap /var/run/openldap/slapd.pid
3.启动ldap server
/etc/init.d/slapd start
4.添加entry
vi a.ldif
dn:dc=pro,dc=com
objectclass:dcObject
objectclass:organization
o:pro,Inc.
dc:pro
dn:cn=admin,dc=pro,dc=com
objectclass:organizationalRole
cn:admin
ldapadd -x -h 127.0.0.1 -D "cn=admin,dc=pro,dc=com" -W -f a.ldif
Enter LDAP Password:
adding new entry "dc=pro,dc=com"
adding new entry "cn=admin,dc=pro,dc=com"
可选:
如果想要查看ldap server的log信息:
1.vi /etc/openldap/slapd.conf
添加:
loglevel 256
2.vi /etc/rsyslog.conf
添加:
local4.* /var/log/ldap.log
3.重启rsyslog
/etc/init.d/rsyslog