Bonjour,

je lis "mastering OpenLDAP…".

J'ai compris comment me connecter en "simple bind", avec "anonymous", en donnant le droit "read" à "anonymous" dans les ACLs. Comme ceci:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
########
# ACLs #
########
access to attrs=userPassword
	by anonymous auth
        by self write
        by * none
access to *
        by self write
	by anonymous read
	by * none
En résultat, ça donne par exemple:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
thierry@thierry-VirtualBox:~$ ldapsearch -x -Z '(uid=immanuel)' -LLL
dn: uid=immanuel,ou=Users,dc=example,dc=com
sn: Kant
ou: Users
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
givenName: Manny
cn: Manny Kant
uid: immanuel
Avec le log correspondant:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
Oct 16 20:42:56 thierry-VirtualBox slapd[3101]: conn=1000 fd=14 ACCEPT from IP=127.0.0.1:33924 (IP=0.0.0.0:389)
Oct 16 20:42:56 thierry-VirtualBox slapd[3101]: conn=1000 op=0 EXT oid=1.3.6.1.4.1.1466.20037
Oct 16 20:42:56 thierry-VirtualBox slapd[3101]: conn=1000 op=0 STARTTLS
Oct 16 20:42:56 thierry-VirtualBox slapd[3101]: conn=1000 op=0 RESULT oid= err=0 qtime=0.000022 etime=0.000128 text=
Oct 16 20:42:57 thierry-VirtualBox slapd[3101]: conn=1000 fd=14 TLS established tls_ssf=256 ssf=256 tls_proto=TLS1.3 tls_cipher=AES-256-GCM
Oct 16 20:42:57 thierry-VirtualBox slapd[3101]: conn=1000 op=1 BIND dn="" method=128
Oct 16 20:42:57 thierry-VirtualBox slapd[3101]: conn=1000 op=1 RESULT tag=97 err=0 qtime=0.000031 etime=0.000405 text=
Oct 16 20:42:57 thierry-VirtualBox slapd[3101]: conn=1000 op=2 SRCH base="dc=example,dc=com" scope=2 deref=0 filter="(uid=immanuel)"
Oct 16 20:42:57 thierry-VirtualBox slapd[3101]: conn=1000 op=2 SEARCH RESULT tag=101 err=0 qtime=0.000024 etime=0.004250 nentries=1 text=
Oct 16 20:42:57 thierry-VirtualBox slapd[3101]: conn=1000 op=3 UNBIND
Oct 16 20:42:57 thierry-VirtualBox slapd[3101]: conn=1000 fd=14 closed
Mon problème vient dès maintenant.

Dans une petite portion de texte, il est écrit que l'on peut utiliser un utilisateur spécial (ici authenticate), que l'on a créé (c'est une entrée du répertoire) avec un mot de passe (secret), pour éviter d'utiliser "anonymous". Dans le principe, j'ai compris. Par contre, je n'arrive pas, soit à réellement comprendre le texte, soit à la mettre en pratique.
Voilà ce qui est écrit: (this problem = utiliser "anonymous")
One way to work around this problem is to use a different user (rather than
Anonymous) to perform the search for the user's DN. In the last chapter, we created
just such an account. Here is the LDIF record we used:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
# Special Account for Authentication:
dn: uid=authenticate,ou=System,dc=example,dc=com
uid: authenticate
ou: System
description: Special account for authenticating users
userPassword: secret
objectClass: account
objectClass: simpleSecurityObject
The purpose of this account is to log into the server and perform searches for DNs.
In other words, it conducts the same job as the Anonymous user, but it adds a little
more security, since clients that use the uid=authenticate account will have to have
the appropriate password, too.
To make this clear let's look at the case where a client, configured to use the
Authenticate account, binds a user that identifies himself as matt with the password
myPassword.

Here's a step-by-step breakdown of what happens when doing a bind operation
this way:

1. Client connects to the server and starts a bind operation with the DN uid=autenticate,ou=system,dc=example,dc=com
and the password secret.
2. The server, as Anonymous, compares the Authenticate password, secret, with the value of the userPassword attribute for the uid=authenticate,ou=system,dc=example,dc=com record.
authenticate
3. If the above succeeds, then the client (now logged in as the Authenticate user) performs a search with the filter: (&(uid=matt)(objectclass=inetOrgPerson)). Since uid is unique, the search should return either 0 or 1 record.
4. If one matching DN is found (in our case, it would be uid=matt,ou=user,dc=example,dc=com), then the client tries to re-bind as this DN, and using the password the user initially supplies to the client (myPassword).
5. The server, as Anonymous, compares the user-supplied password, myPassword, with the value of the userPassword attribute of uid=matt,ou=user,dc=example,dc=com.
6. If the password comparison succeeds then the client application can continue performing LDAP operations as uid=matt,ou=user,dc=example,dc=com.

The process is lengthy and it requires that the client application be configured
with bind DN and password information for the Authenticate user, but it adds an
additional layer of security to an Anonymous bind and search.
Jusqu'au numéro 3, j'arrive à comprendre et à la mettre en œuvre. J'ajoute une ligne dans les ACLs:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
access to *
      by self write
      by dn="uid=authenticate,ou=system,dc=example,dc=com" read
      by * none
Par contre à partir du numéro 4 (4. If one matching DN is found…), je ne comprends pas bien.
Il est écrit que si un DN matche, alors le client essaye de re-binder avec ce DN, ceci en utilisant le mot de passe initialement fourni avec le client myPassword).

Puis vient le numéro 5 et le 6 naturellement.

Quésako ? Comment mettre ça en œuvre ?

Si le 4, 5 et 6 sont indépendants du 1, 2 et 3, alors le sens m'est intelligible. Si ce n'est pas le cas, je ne comprends pas comment mettre en œuvre tout ça. Et comme c'est présenté, j'ai plus l'impression que le 4 vient juste après le 3, et qu'ils ne sont pas indépendants. Qu'est-ce à penser ?

Merci pour votre aide.