Install OpenLDAP 2.4.44 on Redhat/Centos7.

 

1. Disable firewall and selinux

2. yum install -y openldap openldap-clients openldap-servers

3. start/stop/enable/disable ldap service

# systemctl start/restart slapd
# systemctl enable slapd
# systemctl status slapd

4.open log record for ldap , then if you encounter problems, you can check the log and get clues

# vi /etc/rsyslog.conf to add below line.
local4.* /var/log/ldap.log
# systemctl restart rsyslog

5.create /etc/openldap/slapd.conf as below:

include        /etc/openldap/schema/corba.schema
include        /etc/openldap/schema/core.schema
include        /etc/openldap/schema/cosine.schema
include        /etc/openldap/schema/duaconf.schema
include        /etc/openldap/schema/dyngroup.schema
include        /etc/openldap/schema/inetorgperson.schema
include        /etc/openldap/schema/java.schema
include        /etc/openldap/schema/misc.schema
include        /etc/openldap/schema/nis.schema
include        /etc/openldap/schema/openldap.schema
include        /etc/openldap/schema/ppolicy.schema
include        /etc/openldap/schema/collective.schema
allow bind_v2
pidfile        /var/run/openldap/slapd.pid
argsfile        /var/run/openldap/slapd.args
loglevel        4095
access to *
    by self write
    by users read
    by anonymous read
database config
access to *
        by dn.exact="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" manage
        by dn.exact="cn=admin,dc=example,dc=com" manage
        by * none
database monitor
access to *
        by dn.exact="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" read
        by dn.exact="cn=admin,dc=example,dc=com" read
        by * none
database        bdb
suffix          "dc=example,dc=com"
checkpoint      1024 15
cachesize      10000
rootdn          "cn=admin,dc=example,dc=com"
rootpw          {SSHA}xO7YGnx2sl91jBKg+8MzFIRxgh8upp6t
directory      /var/lib/ldap
index objectClass                      eq,pres 
index ou,cn,mail,surname,givenname      eq,pres,sub 
index uidNumber,gidNumber,loginShell    eq,pres 
index uid,memberUid                    eq,pres,sub 
index nisMapName,nisMapEntry            eq,pres,sub

 

6. convert slapd.conf to cn=config format

systemctl stop slapd

rm –rf /etc/openldap/slapd.d

mkdir /etc/openldap/slapd.d

slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d

chown -R ldap:ldap slapd.d/

systemctl start slapd

 

7. create baseDN, People and Groups

create /etc/openldap/base.ldif as below

dn: dc=example,dc=com
dc: example
objectClass: top
objectClass: domain

dn: ou=People,dc=example,dc=com
ou: People
objectClass: top
objectClass: organizationalUnit

dn: ou=Groups,dc=example,dc=com
ou: Groups
objectClass: top
objectClass: organizationalUnit

import these entities to ldap server:

ldapadd -x -w 12345678 -D cn=admin,dc=example,dc=com -f /etc/openldap/base.ldif

 

你可能感兴趣的:(工作点滴)