Table of Contents

Cours LDAP

Cours à télécharger

$servers->setValue('server','base',array('dc=univ-lehavre,dc=fr'));
$servers->setValue('login','bind_id','cn=admin,dc=univ-lehavre,dc=fr');

Nouvelle version OpenLdap (nouvelle configuration)

Quelques commandes utiles

ldapadd -W -D <binddn> -x -H ldap://<serveur> -f <fichier.ldif>
ldapsearch -x -H ldap://<serveur> -b <base> [-s portée] [filtre] [attributs]
ldapdelete -W -D <binddn> -x -H ldap://<serveur> <dn>
ldapmodify -W -D <binddn> -x -H ldap://<serveur> -f <fichier.ldif>
ldapmodrdn -W -D <binddn> -x -H ldap://<serveur> <dn> <nouveau_rdn>
dn: olcDatabase={1}hdb,cn=config
changetype: modify
delete: olcAccess

Fichiers de données

# ldapadd -Y EXTERNAL -H ldapi:/// -f <nom du fichier>.ldif

Création de la base (falcutatif si dpkg-reconfigure slapd)

# Load dynamic backend modules
dn: cn=module,cn=config
objectClass: olcModuleList
cn: module
olcModulepath: /usr/lib/ldap
olcModuleload: {0}back_hdb

# Database settings
dn: olcDatabase=hdb,cn=config
objectClass: olcDatabaseConfig
objectClass: olcHdbConfig
olcDatabase: {1}hdb
olcSuffix: dc=univ-lehavre,dc=fr
olcDbDirectory: /var/lib/ldap
olcRootDN: cn=admin,dc=univ-lehavre,dc=fr
olcRootPW: secret
olcDbConfig: set_cachesize 0 2097152 0
olcDbConfig: set_lk_max_objects 1500
olcDbConfig: set_lk_max_locks 1500
olcDbConfig: set_lk_max_lockers 1500
olcDbIndex: objectClass eq
olcLastMod: TRUE
olcDbCheckpoint: 512 30

Initialisation de l'annuaire (falcutatif si dpkg-reconfigure slapd)

dn: dc=univ-lehavre,dc=fr
objectClass: dcObject
objectClass: organization
dc: univ-lehavre
o: univ-lehavre
description: univ-lehavre

Création de la structure

sudo ldapadd -x -D cn=admin,dc=univ-lehavre,dc=fr -W -f struct.ldif
dn: ou=users,dc=univ-lehavre,dc=fr
objectClass: top
objectClass: organizationalUnit
ou: users

dn: ou=groups,dc=univ-lehavre,dc=fr
objectClass: top
objectClass: organizationalUnit
ou: groups

Ajout des utilisateurs

sudo ldapadd -x -D cn=admin,dc=univ-lehavre,dc=fr -W -f users.ldif
dn: cn=utilisateurs,ou=groups,dc=univ-lehavre,dc=fr
objectClass: posixGroup
cn: utilisateurs
gidNumber: 2000

dn: uid=garfield,ou=users,dc=univ-lehavre,dc=fr
objectClass: account
objectClass: posixAccount
cn: garfield
uid: garfield
uidNumber: 10001
gidNumber: 2000
homeDirectory: /home/garfield
userPassword:: e0NSWVBUfWRhSDJadHI4dElnZFE=

dn: uid=julien,ou=users,dc=univ-lehavre,dc=fr
objectClass: account
objectClass: posixAccount
cn: julien
uid: julien
uidNumber: 10002
gidNumber: 2000
homeDirectory: /home/julien
userPassword:: e0NSWVBUfWRhSDJadHI4dElnZFE=

dn: uid=tom,ou=users,dc=univ-lehavre,dc=fr
objectClass: account
objectClass: posixAccount
cn: tom
uid: tom
uidNumber: 10003
gidNumber: 2000
homeDirectory: /home/tom
userPassword:: e0NSWVBUfWRhSDJadHI4dElnZFE=

dn: uid=dominique,ou=users,dc=univ-lehavre,dc=fr
objectClass: account
objectClass: posixAccount
cn: garfield
uid: garfield
uidNumber: 10004
gidNumber: 2000
homeDirectory: /home/garfield
userPassword:: e0NSWVBUfWRhSDJadHI4dElnZFE=

dn: uid=michel,ou=users,dc=univ-lehavre,dc=fr
objectClass: account
objectClass: posixAccount
cn: michel
uid: michel
uidNumber: 1010
gidNumber: 2000
homeDirectory: /home/michel
userPassword:: e0NSWVBUfWRhSDJadHI4dElnZFE=

dn: uid=stephane,ou=users,dc=univ-lehavre,dc=fr
objectClass: account
objectClass: posixAccount
cn: stephane
uid: stephane
uidNumber: 1011
gidNumber: 2000
homeDirectory: /home/stephane
userPassword:: e0NSWVBUfWRhSDJadHI4dElnZFE=

dn: uid=robert,ou=users,dc=univ-lehavre,dc=fr
objectClass: account
objectClass: posixAccount
cn: robert
uid: robert
uidNumber: 1012
gidNumber: 2000
homeDirectory: /home/robert
userPassword:: e0NSWVBUfWRhSDJadHI4dElnZFE=

dn: uid=jean,ou=users,dc=univ-lehavre,dc=fr
objectClass: account
objectClass: posixAccount
cn: jean
uid: jean
uidNumber: 1013
gidNumber: 2000
homeDirectory: /home/jean
userPassword:: e0NSWVBUfWRhSDJadHI4dElnZFE=

dn: uid=nicolas,ou=users,dc=univ-lehavre,dc=fr
objectClass: account
objectClass: posixAccount
cn: nicolas
uid: nicolas
uidNumber: 1014
gidNumber: 2000
homeDirectory: /home/nicolas
userPassword:: e0NSWVBUfWRhSDJadHI4dElnZFE=

dn: uid=camille,ou=users,dc=univ-lehavre,dc=fr
objectClass: account
objectClass: posixAccount
cn: camille
uid: camille
uidNumber: 1015
gidNumber: 2000
homeDirectory: /home/camille
userPassword:: e0NSWVBUfWRhSDJadHI4dElnZFE=

dn: uid=claire,ou=users,dc=univ-lehavre,dc=fr
objectClass: account
objectClass: posixAccount
cn: claire
uid: claire
uidNumber: 1016
gidNumber: 2000
homeDirectory: /home/claire
userPassword:: e0NSWVBUfWRhSDJadHI4dElnZFE=

dn: uid=nathalie,ou=users,dc=univ-lehavre,dc=fr
objectClass: account
objectClass: posixAccount
cn: nathalie
uid: nathalie
uidNumber: 1017
gidNumber: 2000
homeDirectory: /home/nathalie
userPassword:: e0NSWVBUfWRhSDJadHI4dElnZFE=

dn: uid=antoine,ou=users,dc=univ-lehavre,dc=fr
objectClass: account
objectClass: posixAccount
cn: antoine
uid: antoine
uidNumber: 1018
gidNumber: 2000
homeDirectory: /home/antoine
userPassword:: e0NSWVBUfWRhSDJadHI4dElnZFE=

dn: uid=yoann,ou=users,dc=univ-lehavre,dc=fr
objectClass: account
objectClass: posixAccount
cn: yoann
uid: yoann
uidNumber: 1019
gidNumber: 2000
homeDirectory: /home/yoann
userPassword:: e0NSWVBUfWRhSDJadHI4dElnZFE=

dn: uid=gaetan,ou=users,dc=univ-lehavre,dc=fr
objectClass: account
objectClass: posixAccount
cn: gaetan
uid: gaetan
uidNumber: 1020
gidNumber: 2000
homeDirectory: /home/gaetan
userPassword:: e0NSWVBUfWRhSDJadHI4dElnZFE=