Ldap Server: Difference between revisions

From Objectif Client Inc
Jump to navigation Jump to search
Line 76: Line 76:


==== Clean Backup File ====
==== Clean Backup File ====
<syntaxhighlight lang="bash">cat ldap_backup.ldif | grep -v 'structuralObjectClass' | grep -v 'modifyTimestamp' | grep -v 'modifiersName' | grep -v 'entryCSN' | grep -v 'createTimestamp' | grep -v 'creatorsName' | grep -v 'entryUUID' > /backup/ldap/ldap_backup_clean.ldif</syntaxhighlight>
<syntaxhighlight lang="bash">cat ldap_backup.ldif | grep -v 'structuralObjectClass' | grep -v 'modifyTimestamp' | grep -v 'modifiersName' /
 
| grep -v 'entryCSN' | grep -v 'createTimestamp' | grep -v 'creatorsName' | grep -v 'entryUUID' > /backup/ldap/ldap_backup_clean.ldif</syntaxhighlight>


==== Restore from Ldif ====
==== Restore from Ldif ====
<syntaxhighlight lang="bash">ldapadd -x -D cn=admin,dc=objclt,dc=com -W -f /mnt/Backup/Ldap/ldap_backup_clean.ldif</syntaxhighlight>
<syntaxhighlight lang="bash">ldapadd -x -D cn=admin,dc=objclt,dc=com -W -f /mnt/Backup/Ldap/ldap_backup_clean.ldif</syntaxhighlight>

Revision as of 00:50, 16 May 2016

Installation

Preparation

By default the installation of slapd will create a working configuration based on the hostname. If you want a suffix dc=objclt,dc=com then your host file "/etc/hosts" would have a line similar to this:

127.0.1.1   hostname.objclt.com  hostname

Install

Install Ldap server and utilities

apt-get install slapd ldap-utils

Validate your install

Inquiry the Ldap configuration

ldapsearch -Q -LLL -Y EXTERNAL -H ldapi:/// -b cn=config dn
dn: cn=config
dn: cn=module{0},cn=config
dn: cn=schema,cn=config
dn: cn={0}core,cn=schema,cn=config
dn: cn={1}cosine,cn=schema,cn=config
dn: cn={2}nis,cn=schema,cn=config
dn: cn={3}inetorgperson,cn=schema,cn=config
dn: olcBackend={0}mdb,cn=config
dn: olcDatabase={-1}frontend,cn=config
dn: olcDatabase={0}config,cn=config
dn: olcDatabase={1}mdb,cn=config

Explanation of entries

  1. cn=config: global settings
  2. cn=module{0},cn=config: a dynamically loaded module
  3. cn=schema,cn=config: contains hard-coded system-level schema
  4. cn={0}core,cn=schema,cn=config: the hard-coded core schema
  5. cn={1}cosine,cn=schema,cn=config: the cosine schema
  6. cn={2}nis,cn=schema,cn=config: the nis schema
  7. cn={3}inetorgperson,cn=schema,cn=config: the inetorgperson schema
  8. olcBackend={0}hdb,cn=config: the 'hdb' backend storage type
  9. olcDatabase={-1}frontend,cn=config: frontend database, default settings for other databases
  10. olcDatabase={0}config,cn=config: slapd configuration database (cn=config)
  11. olcDatabase={1}hdb,cn=config: your database instance (dc=examle,dc=com)

Display the dc=objclt,dc=com DIT

ldapsearch -x -LLL -H ldap:/// -b dc=objclt,dc=com dn

Setup Ldap

Change Root DN

Retreive current information

ldapsearch -LLL -Y EXTERNAL -H ldapi:/// -b  cn=config dn olcRootDN

You need to modify the entry dn: "olcDatabase={1}hdb,cn=config"

Proceed to modify

ldapmodify -Y EXTERNAL -H ldapi:///

First, enter the entry we want to modify

dn: olcDatabase={1}mdb,cn=config

Second, type the parameter we want to modify

replace: olcRootDN

Third, type the new value you want

olcRootDN: cn=admin,dc=objclt,dc=com

Press enter twice to confirm

Add a new Schema

Add Samba Schema

ldapadd -Q -Y EXTERNAL -H ldapi:/// -f samba.ldif

Backup / Restore

Backup

/usr/sbin/slapcat -l /mnt/Backup/Ldap/ldap_backup.ldif

Restore

Clean Backup File

cat ldap_backup.ldif | grep -v 'structuralObjectClass' | grep -v 'modifyTimestamp' | grep -v 'modifiersName' / 
| grep -v 'entryCSN' | grep -v 'createTimestamp' | grep -v 'creatorsName' | grep -v 'entryUUID' > /backup/ldap/ldap_backup_clean.ldif

Restore from Ldif

ldapadd -x -D cn=admin,dc=objclt,dc=com -W -f /mnt/Backup/Ldap/ldap_backup_clean.ldif