LDAP et carnet d`adresses mail

Transcription

LDAP et carnet d`adresses mail
LDAP et carnet d'adresses mail
I)Installation Open-LDAP v1 (Conf dans l'annuaire LDAP, cn=config)
apt-get install slapd ldap-utils
1)Suppression de la base par défaut
rm /etc/ldap/slapd.d/cn\=config/olcDatabase={1}hdb.ldif
rm /var/lib/ldap/*
/etc/init.d/slapd restart
2)Ajout des schémas
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/cosine.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/nis.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/inetorgperson.ldif
3)Crypter mdp superutilisateur et utilisateur
slappasswd -h {SSHA}
4)Template LDAP
mkdir /cheminRepertoireTemplates_ldiff/
5)Dossier de l'annuaire LDAP
mkdir /cheminRepertoireStockageAnnuaireLDAP /nomAnnuaireLDAP/
chown -R openldap:openldap /cheminRepertoireStockageAnnuaireLDAP/nomAnnuaireLDAP/
6)Insertion de votre chemin base LDAP et de log
nano /etc/apparmor.d/usr.sbin.slapd
//Début fichier
/cheminRepertoireStockageAnnuaireLDAP/nomAnnuaireLDAP/ r,
/cheminRepertoireStockageAnnuaireLDAP/nomAnnuaireLDAP/** rwk,
/cheminRepertoireLog/ r,
/cheminRepertoireLog/** rwk,
//Fin fichier
service apparmor restart
7)SSL/TLS
Installation openssl : apt-get install gnutls-bin
mkdir /etc/ldap/ssl/
Créer une clé privée : certtool --generate-privkey --outfile /etc/ldap/ssl/ldap-ca-key.pem
Créer un certificat autosigné : certtool --generate-self-signed --load-privkey /etc/ldap/ssl/ldap-cakey.pem --outfile /etc/ldap/ssl/ldap-ca-cert.crt
Common name: domaine.ext
The certificate will expire in (days): 3650
1
Path length constraint (decimal, -1 for no constraint): -1
Enter the dnsName of the subject of the certificate:domaine.ext
Does the certificate belong to an authority? (y/N): n
Is this a TLS web client certificate? (y/N): y
Is this also a TLS web server certificate? (y/N): y
Enter the dnsName of the subject of the certificate:ldapMobois.mob
Will the certificate be used to sign other certificates? (y/N): y
Will the certificate be used for signing (DHE and RSA-EXPORT ciphersuites)? (y/N): n
Will the certificate be used for encryption (RSA ciphersuites)? (y/N): y
Will the certificate be used to sign other certificates? (y/N): y
Will the certificate be used to sign CRLs? (y/N): y
Will the certificate be used to sign code? (y/N): y
Will the certificate be used to sign OCSP requests? (y/N): y
Will the certificate be used for time stamping? (y/N): y
Is the above information ok? (Y/N): y
adduser openldap ssl-cert
chown openldap:ssl-cert /etc/ldap/ssl/ldap-ca-key.pem
nano /etc/default/slapd
//Début fichier
SLAPD_SERVICES="ldap:/// ldapi:/// ldaps:///"
//Fin fichier
nano /etc/ldap/ldap.conf
//Début fichier
TLS_REQCERT never
//Fin fichier
/etc/init.d/slapd restart
8)Création du fichier de conf général
nano /cheminRepertoireTemplates_ldiff/configGlobal.ldiff
//Début fichier
#Modifie le niveau de logs
dn:cn=config
changetype:modify
replace:olcLogLevel
olcLogLevel:stats
#olcLogLevel:any #mod débug
#Modifie le chemin des logs
2
dn:cn=config
changetype:modify
replace:olcLogFile
olcLogFile:/cheminRepertoireLog/openldap.log
#Modifie le timeout
dn:cn=config
changetype: modify
replace:olcIdleTimeout
olcIdleTimeout:30
#Authorisé bind_v2
dn:cn=config
changetype: modify
replace:olcAllows
olcAllows:bind_v2
#LDAP SSL/TLS
dn: cn=config
changetype: modify
replace:olcTLSCipherSuite
dn: cn=config
changetype: modify
replace:olcTLSCipherSuite
olcTLSCipherSuite:NORMAL
dn: cn=config
changetype: modify
replace:olcTLSCRLCheck
olcTLSCRLCheck:none
dn: cn=config
changetype: modify
replace:olcTLSVerifyClient
dn: cn=config
3
changetype: modify
replace:olcTLSCertificateKeyFile
olcTLSCertificateKeyFile:/etc/ldap/ssl/ldap-ca-cert.pem
dn: cn=config
changetype: modify
replace:olcTLSCACertificateFile
olcTLSCACertificateFile:/etc/ldap/ssl/ldap-ca-key.pem
//Fin fichier
Test du certificat : ldapsearch -LLL -Y EXTERNAL -H ldapi:/// -b cn=config|grep Certificate
9)Création du fichier de conf des modules
nano /cheminRepertoireTemplates_ldiff/configModule.ldiff
//Début fichier
# Load dynamic backend modules
dn:cn=module,cn=config
objectClass:olcModuleList
cn:module
olcModulepath:/usr/lib/ldap
olcModuleload:back_hdb.la
//Fin fichier
10)Création du fichier de conf des schema
nano /cheminRepertoireTemplates_ldiff/configSchema.ldiff
//Début fichier
#Load Schema
dn: cn=schema,cn=config
objectClass: olcSchemaConfig
cn: schema
#Load Thunderbird Schema si besoin carnet d'adresse LDAP
dn: cn=Thunderbird,cn=schema,cn=config
objectClass: olcSchemaConfig
cn: Thunderbird
olcAttributeTypes: ( 1.3.6.1.4.1.13769.2.1.1
NAME ( 'xmozillanickname' 'mozillaNickname' )
SUP name )
olcAttributeTypes: ( 1.3.6.1.4.1.13769.2.1.2
NAME ( 'xmozillausehtmlmail' 'mozillaUseHtmlMail' )
4
SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
SINGLE-VALUE )
olcAttributeTypes: ( 1.3.6.1.4.1.13769.2.1.3
NAME 'mozillaSecondEmail'
EQUALITY caseIgnoreIA5Match
SUBSTR caseIgnoreIA5SubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )
olcAttributeTypes: ( 1.3.6.1.4.1.13769.2.1.4
NAME 'mozillaHomeLocalityName'
EQUALITY caseIgnoreMatch
SUBSTR caseIgnoreSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )
olcAttributeTypes: ( 1.3.6.1.4.1.13769.2.1.5
NAME 'mozillaPostalAddress2'
EQUALITY caseIgnoreListMatch
SUBSTR caseIgnoreListSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )
olcAttributeTypes: ( 1.3.6.1.4.1.13769.2.1.6
NAME 'mozillaHomePostalAddress2'
EQUALITY caseIgnoreListMatch
SUBSTR caseIgnoreListSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )
olcAttributeTypes: ( 1.3.6.1.4.1.13769.2.1.7
NAME ( 'mozillaHomeState' ) SUP name )
olcAttributeTypes: ( 1.3.6.1.4.1.13769.2.1.8
NAME 'mozillaHomePostalCode'
EQUALITY caseIgnoreMatch
SUBSTR caseIgnoreSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{40} )
olcAttributeTypes: ( 1.3.6.1.4.1.13769.2.1.9
5
NAME ( 'mozillaHomeCountryName' )
SUP name SINGLE-VALUE )
olcAttributeTypes: ( 1.3.6.1.4.1.13769.2.1.10
NAME ( 'mozillaHomeFriendlyCountryName' )
EQUALITY caseIgnoreMatch
SUBSTR caseIgnoreSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
olcAttributeTypes: ( 1.3.6.1.4.1.13769.2.1.11
NAME ( 'homeurl' 'mozillaHomeUrl' )
EQUALITY caseIgnoreIA5Match
SUBSTR caseIgnoreIA5SubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )
olcAttributeTypes: ( 1.3.6.1.4.1.13769.2.1.12
NAME ( 'workurl' 'mozillaWorkUrl' )
EQUALITY caseIgnoreIA5Match
SUBSTR caseIgnoreIA5SubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )
olcAttributeTypes: ( 1.3.6.1.4.1.13769.2.1.13
NAME ( 'nsAIMid' )
DESC 'AOL Instant Messenger (AIM) Identity'
EQUALITY telephoneNumberMatch
SUBSTR telephoneNumberSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 )
olcAttributeTypes: ( 1.3.6.1.4.1.13769.2.1.96
NAME ( 'custom1' 'mozillaCustom1' )
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
SINGLE-VALUE )
olcAttributeTypes: ( 1.3.6.1.4.1.13769.2.1.97
NAME ( 'custom2' 'mozillaCustom2' )
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
SINGLE-VALUE )
6
olcAttributeTypes: ( 1.3.6.1.4.1.13769.2.1.98
NAME ( 'custom3' 'mozillaCustom3' )
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
SINGLE-VALUE )
olcAttributeTypes: ( 1.3.6.1.4.1.13769.2.1.99
NAME ( 'custom4' 'mozillaCustom4' )
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
SINGLE-VALUE )
olcObjectClasses: ( 1.3.6.1.4.1.13769.2.2.1
NAME 'mozillaAbPersonObsolete'
SUP inetOrgPerson
STRUCTURAL
MAY (
mozillaNickname $
mozillaUseHtmlMail $
mozillaSecondEmail $
mozillaPostalAddress2 $
mozillaHomePostalAddress2 $
mozillaHomeLocalityName $
mozillaHomeState $
mozillaHomePostalCode $
mozillaHomeCountryName $
mozillaHomeFriendlyCountryName $
mozillaHomeUrl $
mozillaWorkUrl $
mozillaCustom1 $
mozillaCustom2 $
mozillaCustom3 $
mozillaCustom4 $
nsAIMid $
c$
co ) )
//Fin fichier
7
11)Création du fichier de conf de l'annuaire LDAP
nano /cheminRepertoireTemplates_ldiff/nomConfigAnnuaireLDAP.ldiff
//Début fichier
# Create the database
dn: olcDatabase=hdb,cn=config
#>>Type de l'objet courant faisant partie des classes suivantes
objectClass: olcDatabaseConfig
objectClass: olcHdbConfig
#>>Type de base
olcDatabase: {1}hdb
#>>DCs de la base ldap
olcSuffix: dc=nomAnnuaireLDAP,dc= ExtensionAnnuaireLDAP
#Dossier de stockage de la base ldap
olcDbDirectory: /cheminRepertoireStockageAnnuaireLDAP/nomAnnuaireLDAP/
#Definition du compte Manager interne
olcRootDN: cn=admin,dc=nomAnnuaireLDAP,dc= ExtensionAnnuaireLDAP
#Definition du mot de passe associe au compte Manager
olcRootPW: {SSHA}XXXXXXXXXXXXX
#>>Nombre de resultat affiche lors d'une recherche
olcDbConfig: set_cachesize 0 2097152 0
olcDbConfig: set_lk_max_objects 1500
olcDbConfig: set_lk_max_locks 1500
olcDbConfig: set_lk_max_lockers 1500
#>>Gestion des Index
olcDbIndex: objectClass eq
olcLastMod: TRUE
olcDbCheckpoint: 512 30
#>>ACL (droits d'accès) sur la base LDAP
#ACL1, modification de mots de passes
olcAccess: to attrs=userPassword by
dn="cn=admin,dc=nomAnnuaireLDAP,dc=ExtensionAnnuaireLDAP" write by anonymous auth
by self write by users read by * none
olcAccess: to attrs=shadowLastChange by
dn="cn=admin,dc=nomAnnuaireLDAP,dc=ExtensionAnnuaireLDAP" write by users read by self
write by * none
olcAccess: to dn.base="" by
dn="cn=admin,dc=nomAnnuaireLDAP,dc=ExtensionAnnuaireLDAP" write by users read by self
write by * none
8
olcAccess: to * by dn="cn=admin,dc=nomAnnuaireLDAP,dc=ExtensionAnnuaireLDAP" write by
users read by self write by * none
//Fin fichier
12)Création de fichier de conf d'une OU et d'un objet CN (exemple pour carnet d'adresse)
nano /cheminRepertoireTemplates_ldiff/nomOu-Objects.ldiff
//Début fichier
#>>Racine de la base ldap
dn: dc=nomAnnuaireLDAP,dc=ExtensionAnnuaireLDAP
objectClass: dcObject
objectclass: organization
o: nomAnnuaireLDAP.ExtensionAnnuaireLDAP
dc: nomAnnuaireLDAP
description: ldap nomAnnuaireLDAP
#Admin user
dn: cn=admin, dc=nomAnnuaireLDAP,dc=ExtensionAnnuaireLDAP
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: admin
description: LDAP admin
userPassword: {SSHA}XXXXXXXXXXXXX //A remplacer avec le bon hash
#>>OU d'un carnet d'adresse
dn:ou=addressbook,dc=nomAnnuaireLDAP,dc=ExtensionAnnuaireLDAP
objectClass:organizationalUnit
ou: addressbook
#Donnée d'un carnet d'adresse
dn:uid=prenom.nom,ou=addressbook,dc=nomAnnuaireLDAP,dc=ExtensionAnnuaireLDAP
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
#Si Schéma Thunderbird fonctionnel
objectClass: mozillaAbPersonObsolete
#Fin si
cn: prenom nom
uid: prenom.nom
description: Commentaires
facsimileTelephoneNumber: FAX
displayName: Prenom Nom
givenName: Prenom
9
homePhone: Telephone personel
homePostalAddress: Adresse personnelle
mobile: Telephone GSM
pager: Numero de pager
sn: Nom
telephoneNumber: Telephone professionel
o: Societe
ou: Travail - Departement
postOfficeBox: Adresse professionnelle
l: Travail - Ville
st: Travail - Etat
c: Travail - Pays
title: Travail – Titre
mail: [email protected]
postalCode: Travail – CP
#Si Schéma Thunderbird fonctionnel
xmozillanickname: Pseudonyme
nsAIMid: Identifiant AIM
mozillaSecondEmail: Autre adresse mail
mozillaHomeLocalityName: Ville
mozillaHomeCountryName: Pays
homeurl: Page web perso
mozillaHomePostalCode: CP
mozillaHomeState: Etat
workurl: Travail - Site web
custom1: Personnalise 1
custom2: Personnalise 2
custom3: Personnalise 3
custom4: Personnalise 4
mozillaHomePostalAddress2: Adresse personnelle suite
mozillaPostalAddress2: Adresse professionnelle suite
#Fin si
#OU Utilisateur
dn: ou=users,dc=nomAnnuaireLDAP,dc=ExtensionAnnuaireLDAP
objectClass: organizationalUnit
ou: users
10
#Objet Utilisateur
#User IN
dn: uid=nomUser,ou=users,dc=nomAnnuaireLDAP,dc=ExtensionAnnuaireLDAP
objectClass: shadowAccount
objectClass: inetOrgPerson
cn: nomUser
uid: nomUser
sn: nomUser
userPassword: {SSHA}XXXXXXXXXXXXX //A remplacer avec le bon hash
//Fin fichier
13)Création des ACL pour l'utilisateur
//Par exemple, si le repertoire contient des entrées nommées :
0: o=suffix
1: cn=Manager,o=suffix
2: ou=people,o=suffix
3: uid=kdz,ou=people,o=suffix
4: cn=addresses,uid=kdz,ou=people,o=suffix
5: uid=hyc,ou=people,o=suffix
Quand :
olcAccess: to * by dn.base="ou=people,o=suffix" match 2;
olcAccess: to * by dn.one="ou=people,o=suffix" match 3, and 5;
olcAccess: to * by dn.subtree="ou=people,o=suffix" match 2, 3, 4, and 5; and
olcAccess: to * by dn.children="ou=people,o=suffix" match 3, 4, and 5.
Liste de la portée des droits :
11
nano /cheminRepertoireTemplates_ldiff/ACLs.ldiff
//Début fichier
#>>Modifier les ACL pour ajouter le nouvel utilisateur
#Suppression de la règle jocker *
dn: olcDatabase={1}hdb,cn=config
changetype: modify
delete: olcAccess
olcAccess: to * by dn="cn=admin,dc=nomAnnuaireLDAP,dc=ExtensionAnnuaireLDAP" write by
users read by self write by * none
#Ajout de la regle pour le nouvel utilisateur
dn: olcDatabase={1}hdb,cn=config
changetype: modify
add: olcAccess
olcAccess: to dn.subtree="ou=nomUser,dc=nomAnnuaireLDAP,dc=ExtensionAnnuaireLDAP"
by dn="ou=addressbook,dc=nomAnnuaireLDAP,dc=ExtensionAnnuaireLDAP" write by * none
#Ajout de la règle utilisateur suivi de la règle jocker * à la fin
dn: olcDatabase={1}hdb,cn=config
changetype: modify
add: olcAccess
olcAccess: to * by dn="cn=admin,dc=nomAnnuaireLDAP,dc=ExtensionAnnuaireLDAP" write by
users read by self write by * none
14)Intégration des conf
ldapadd -Y EXTERNAL -H ldapi:/// -f /cheminRepertoireTemplates_ldiff/configGlobal.ldiff -v
ldapadd -Y EXTERNAL -H ldapi:/// -f /cheminRepertoireTemplates_ldiff/configModule.ldiff -v
ldapadd -Y EXTERNAL -H ldapi:/// -f /cheminRepertoireTemplates_ldiff/configSchema.ldiff -v
ldapadd -Y EXTERNAL -H ldapi:/// -f
/cheminRepertoireTemplates_ldiff/nomConfigAnnuaireLDAP.ldiff -v
ldapadd -x -D cn=admin, dc=nomAnnuaireLDAP,dc=ExtensionAnnuaireLDAP -w
motDePassAdmin -f /cheminRepertoireTemplates_ldiff/nomOu-Objects.ldiff -v
ldapadd -x -D cn=admin, dc=nomAnnuaireLDAP,dc=ExtensionAnnuaireLDAP -w
motDePassAdmin -f /cheminRepertoireTemplates_ldiff/ACLs.ldiff -v
15)Test de la conf
ldapsearch -LLL -Y EXTERNAL -H ldapi:/// -b "cn=config"
ldapsearch -LLL -Y EXTERNAL -H ldaps:/// -b "cn=config"
//Retourne l'ensemble des éléments de configuration
ldapsearch -LLL -Y EXTERNAL -H ldapi:/// -b
"dc=nomAnnuaireLDAP,dc=ExtensionAnnuaireLDAP"
//Retourne le contenu de l'annuaire LDAP
16)Autre commande
a)Supprimer un objet ldap
ldapdelete -v -D
"uid=nomUID,ou=nomOU,dc=nomAnnuaireLDAP,dc=ExtensionAnnuaireLDAP"
12
b)Sauvegarde de l'Annuaire
slapcat -l fichierDeSauvegarde.ldif -b "dc=nomAnnuaireLDAP ,dc=ExtensionAnnuaireLDAP"
b)Modifier un objet
#Exemple : Objet Utilisateur
nano /cheminRepertoireTemplates_ldiff/modifyNomOu-Objects.ldiff
//Début fichier
dn:uid=nomUser, ou=nomOU,dc=nomAnnuaireLDAP ,dc=ExtensionAnnuaireLDAP
changetype: modify
replace: mobile
mobile:numeroMobile
//Fin fichier
ldapmodify -Y EXTERNAL -H ldapi:/// -f /cheminRepertoireTemplates_ldiff/modifyNomOuObjects.ldiff
II)Installation Open-LDAP v2 (Conf dans Fichier, obsolète)
apt-get install slapd ldap-utils
1)Téléchargement du schéma Thunderbird
//Schema Thunderbird
cd /etc/ldap/schema
wget http://www.lestat.st/_media/informatique/docs/ldap_addbook/mozilla_op20.schema.gz
gunzip -d mozilla_op20.schema.gz
2)Insertion de votre chemin base LDAP et des logs
nano /etc/apparmor.d/usr.sbin.slapd
//Début fichier
/cheminRepertoireStockageAnnuaireLDAP /nomAnnuaireLDAP / r,
/cheminRepertoireStockageAnnuaireLDAP /nomAnnuaireLDAP /** rwk,
/cheminRepertoireLog/ r,
/cheminRepertoireLog/** rwk,
//Fin fichier
service apparmor restart
3)Répertoire des Templates LDAP
mkdir /cheminRepertoireTemplates_ldiff/
4)Dossier de l'annuaire LDAP
mkdir /cheminRepertoireStockageAnnuaireLDAP/nomAnnuaireLDAP/
chown -R openldap:openldap /cheminRepertoireStockageAnnuaireLDAP/nomAnnuaireLDAP/
5)Configuration de LDAP
nano /usr/share/slapd/slapd.conf
//Début fichier
13
# Autoriser les connexion en proto v2
allow bind_v2
include
/etc/ldap/schema/mozilla_op20.schema
pidfile
/var/run/openldap/slapd.pid
argsfile
/var/run/openldap/slapd.args
#Niveau des logs et chemin
loglevel
256
logfile /cheminRepertoireLog/openldap.log
#Définition de la base
database
suffix
bdb
“dc=nomAnnuaireLDAP,dc=ExtensionAnnuaireLDAP"
#Utilisateur Admin
rootdn
“cn=admin,dc=nomAnnuaireLDAP,dc=ExtensionAnnuaireLDAP"
rootpw
motDePasse
checkpoint
32
30
#Chemin de la base
directory
/cheminRepertoireStockageAnnuaireLDAP /nomAnnuaireLDAP
# Definition de indexes
index objectClass
eq
# Modification des ACL
access to attrs=userPassword,shadowLastChange
by dn="cn=admin,dc=nomAnnuaireLDAP ,dc=ExtensionAnnuaireLDAP" write
by anonymous auth
by self write
by * none
access to *
by dn="cn=admin,dc=nomAnnuaireLDAP ,dc=ExtensionAnnuaireLDAP" write
by * read
//Fin fichier
6)Test du fichier de conf
/usr/sbin/slaptest -f /usr/share/slapd/slapd.conf
7)Redémarrage du service
/etc/init.d/slapd restart
14