Contents
# yum -y install openldap openldap-clients openldap-servers
# /usr/sbin/slapd -VVV @(#) $OpenLDAP: slapd 2.4.40 (Nov 10 2015 09:41:16) $ mockbuild@c6b8.bsys.dev.centos.org:/builddir/build/BUILD/ openldap-2.4.40/openldap-2.4.40/build-servers/servers/slapd Included static backends: config ldif monitor bdb hdb ldap mdb meta null passwd relay shell sock
[~] # /etc/init.d/slapd status slapd is stopped [~] # /etc/init.d/slapd restart Stopping slapd: [FAILED] Starting slapd: [ OK ] [~] # chkconfig slapd on [~] # netstat -ntulp | grep slapd tcp 0 0 0.0.0.0:389 0.0.0.0:* LISTEN 2690/slapd tcp 0 0 :::389 :::* LISTEN 2690/slapd [~] # iptables -nvL | grep 389 [~] # ]# ps -e fuwww | grep l[d]ap ldap 11986 0.0 0.2 560100 5660 ? Ssl 18:03 0:00 /usr/sbin/slapd -h ldap:/// ldapi:/// -u ldap
# ldapsearch -Y EXTERNAL -H ldapi:/// -b "cn=config"
# ldapsearch -H ldapi:// -Y EXTERNAL -b "cn=config" -LLL -Q "olcDatabase=*" dn dn: olcDatabase={-1}frontend,cn=config dn: olcDatabase={0}config,cn=config dn: olcDatabase={1}monitor,cn=config dn: olcDatabase={2}hdb,cn=config
# cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
# cd /etc/openldap/slapd.d/
# ldapsearch -LLL -x -h localhost -p 389 -b '' -s base '(&)' namingContexts dn: namingContexts: dc=my-domain,dc=com
# ldapsearch -Q -Y EXTERNAL -H ldapi:/// -s base '(&)' namingContexts
# ldapsearch -LLL -x -h localhost -s base dn: objectClass: top objectClass: OpenLDAProotDSE
[~] # ldapsearch SASL/DIGEST-MD5 authentication started Please enter your password: ldap_sasl_interactive_bind_s: Invalid credentials (49) additional info: SASL(-13): user not found: no secret in database [~] # ldapsearch -x # extended LDIF # # LDAPv3 # base <> (default) with scope subtree # filter: (objectclass=*) # requesting: ALL # # search result search: 2 result: 32 No such object # numResponses: 1
# slappasswd New password: Re-enter new password: {SSHA}3u4JMk96UgMheppVZpdr7HmMJFKHRpEd
# vim "/etc/openldap/slapd.d/cn=config/olcDatabase={2}bdb.ldif"
-olcSuffix: dc=my-domain,dc=com +olcSuffix: dc=example,dc=org -olcRootDN: cn=Manager,dc=my-domain,dc=com +olcRootDN: cn=Manager,dc=example,dc=org +olcRootPW: {SSHA}44qvcGE22p2qwgbTH49PNRZjjRs6PIZ4
# vim "/etc/openldap/slapd.d/cn=config/olcDatabase={1}monitor.ldif"
- nal,cn=auth" read by dn.base="cn=manager,dc=my-domain,dc=com" read by * n + nal,cn=auth" read by dn.base="cn=manager,dc=example,dc=org" read by * n
# cat openldap_initial.ldif
dn: olcDatabase={1}monitor,cn=config changetype: modify replace: olcAccess olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" read by dn.base="cn=admin,dc=example,dc=org" read by * none dn: olcDatabase={2}bdb,cn=config changetype: modify replace: olcSuffix olcSuffix: dc=example,dc=org - replace: olcRootDN olcRootDN: cn=admin,dc=example,dc=org - add: olcRootPW olcRootPW: {SSHA}3u4JMk96UgMheppVZpdr7HmMJFKHRpEd
# ldapmodify -Q -Y EXTERNAL -H ldapi:/// -f /root/openldap_initial.ldif
# ldapsearch -LLLL -Q -Y EXTERNAL -H ldapi:/// -s base '(&)' namingContexts dn: namingContexts: dc=example,dc=org
# example.gr dn: dc=example,dc=org dc: example objectClass: dcObject objectClass: organizationalUnit ou: example.gr
# Domains dn: ou=Domains,dc=example,dc=org objectClass: organizationalUnit ou: Domains # Users dn: ou=People,dc=example,dc=org objectClass: organizationalUnit ou: People # Groups dn: ou=Groups,dc=example,dc=org objectClass: organizationalUnit ou: Groups
# New Domain dn: dc=example.gr,ou=Domains,dc=example,dc=org dc: example.gr objectclass: dNSDomain objectclass: top
dn: uid=test,ou=People,dc=example,dc=org objectClass: top objectClass: person objectClass: organizationalPerson objectClass: inetOrgPerson objectClass: posixAccount mail: username@example.gr cn: username example sn: example givenName: username uid: test uidNumber: 99 gidNumber: 12 homeDirectory: /Maildir/test userPassword: test
# ldapmodify -x -W -D cn=Manager,dc=example,dc=org -a -f example.ldif Enter LDAP Password: adding new entry "dc=example,dc=org" adding new entry "ou=Users,dc=example,dc=org" adding new entry "uid=test,ou=Users,dc=example,dc=org" ## # ldapadd -Q -Y EXTERNAL -H ldapi:/// -f /root/openldap_initial.ldif
# /usr/bin/ldapvi --discover --host localhost
# cd /var/lib/ldap/ # db_checkpoint -1 or # db_checkpoint -1 /var/lib/ldap/
# db_archive -a -h /var/lib/ldap/
# db_archive -d -h /var/lib/ldap/
# /etc/init.d/openldap restart