mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Valery Kharseko
12 hours ago 6d9e1fcbf5d7d59a25d22d7369c70c2d65cabb56
Document phpLDAPadmin Docker setup and delegated access (#1342)

## Summary

- Add an AsciiDoc How-To for connecting phpLDAPadmin v2 to OpenDJ with
Docker Compose.
- Show how to create a login and delegate user administration and
password resets below the People organizational unit.
- Include screenshots of the login form and the directory after sign-in.
- Use the Antora document title and anchor pattern from #1321 for the
phpLDAPadmin page.
- Check the title of every generated Antora page during Maven
verification, including pages whose headers come from ROOT partials.
- Accept `:title:` overrides on pages with a document header and require
a nonblank resolved title.

## Verification

- Ran OpenDJ and phpLDAPadmin in Docker Compose. Signed in and saved an
entry update through phpLDAPadmin.
- Verified delegated entry creation, deletion, and password reset in
OpenDJ, along with denial of writes outside the delegated scope.
- Rendered both screenshots with Asciidoctor and validated the How-To
cross-references.
- Confirmed that the all-page scan detects the original missing document
title.
- Ran all 18 `AntoraPageTitlesIT` cases and 26 documentation tests on
JDK 21. The title tests cover a heading with `:title:`, a standalone
`:title:`, and a section heading without a document header.
- Checked 652 cross-guide file references across 80 pages.
- Built Antora from the Maven-generated sources and verified titles on
all 81 pages. Checked the phpLDAPadmin page heading, browser title,
sidebar, breadcrumbs, How-To index, both screenshots, and all six
anchors.
2 files modified
3 files added
266 ■■■■■ changed files
opendj-doc-generated-ref/src/main/asciidoc/how-to/index.adoc 1 ●●●●● patch | view | raw | blame | history
opendj-doc-generated-ref/src/main/asciidoc/how-to/phpldapadmin.adoc 156 ●●●●● patch | view | raw | blame | history
opendj-doc-generated-ref/src/main/asciidoc/images/phpldapadmin-directory.png patch | view | raw | blame | history
opendj-doc-generated-ref/src/main/asciidoc/images/phpldapadmin-login.png patch | view | raw | blame | history
opendj-doc-generated-ref/src/test/java/org/openidentityplatform/opendj/doc/AntoraPageTitlesIT.java 109 ●●●●● patch | view | raw | blame | history
opendj-doc-generated-ref/src/main/asciidoc/how-to/index.adoc
@@ -28,6 +28,7 @@
include::./tasks.adoc[]
include::./kubernetes.adoc[]
include::./phpldapadmin.adoc[]
include::./bcfks.adoc[]
include::./jdbc-backend.adoc[]
include::./embedded-ldap.adoc[]
opendj-doc-generated-ref/src/main/asciidoc/how-to/phpldapadmin.adoc
New file
@@ -0,0 +1,156 @@
////
The contents of this file are subject to the terms of the Common Development and
Distribution License (the License). You may not use this file except in compliance with the
License.
You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
specific language governing permission and limitations under the License.
When distributing Covered Software, include this CDDL Header Notice in each file and include
the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
Header, with the fields enclosed by brackets [] replaced by your own identifying
information: "Portions copyright [year] [name of copyright owner]".
Copyright 2026 3A Systems, LLC.
////
:table-caption!:
ifndef::env-site[]
[#how-to-phpldapadmin]
endif::[]
== Connect phpLDAPadmin to OpenDJ in Docker
ifdef::env-site[]
anchor:how-to-phpldapadmin[]
endif::[]
This recipe uses Docker Compose to run OpenDJ and phpLDAPadmin (PLA) v2 for local testing. PLA reaches OpenDJ at `opendj:1389` on the Compose network. The example uses plain LDAP on that network and publishes the PLA web interface over HTTP on the host's loopback address.
=== Start OpenDJ and phpLDAPadmin
In an empty directory, save the following as `compose.yaml`. OpenDJ creates the base entry `dc=example,dc=com` in a new instance. The named volume keeps the instance when you replace the container. See xref:../install-guide/chap-install.adoc#install-docker[Running OpenDJ in Docker].
[source,yaml]
----
services:
  opendj:
    image: openidentityplatform/opendj:5.2.0
    init: true
    environment:
      ROOT_PASSWORD: "${OPENDJ_ROOT_PASSWORD:?Set OPENDJ_ROOT_PASSWORD}"
      ADD_BASE_ENTRY: --addBaseEntry
    volumes:
      - opendj-data:/opt/opendj/data
    stop_grace_period: 60s
  pla:
    image: phpldapadmin/phpldapadmin:2.3.13
    depends_on:
      opendj:
        condition: service_healthy
    environment:
      LDAP_HOST: opendj
      LDAP_PORT: "1389"
      LDAP_BASE_DN: "dc=example,dc=com"
      LDAP_LOGIN_ATTR: DN
      LDAP_LOGIN_OBJECTCLASS: inetOrgPerson
    ports:
      - "127.0.0.1:8080:8080"
volumes:
  opendj-data:
----
Set the initial password for `cn=Directory Manager` and run the commands in this recipe from the same Bash session.
[source,bash]
----
read -r -s -p 'OpenDJ Directory Manager password: ' OPENDJ_ROOT_PASSWORD
printf '\n'
export OPENDJ_ROOT_PASSWORD
docker compose up -d --wait
----
=== Create a PLA Login
PLA needs an LDAP entry for the login DN. The default OpenDJ bind DN `cn=Directory Manager` is an alternate bind DN with no entry at that location. Use it to create the delegate with the `inetOrgPerson` object class configured in PLA. See the link:https://github.com/leenooks/phpLDAPadmin/wiki/FAQ[phpLDAPadmin FAQ] for the login requirements.
[source,bash]
----
docker compose exec -T opendj /opt/opendj/bin/ldapmodify \
  --hostname localhost --port 1389 --bindDN 'cn=Directory Manager' \
  --bindPassword "$OPENDJ_ROOT_PASSWORD" <<'LDIF'
dn: uid=pla-user,dc=example,dc=com
changetype: add
objectClass: inetOrgPerson
uid: pla-user
cn: PLA User
sn: User
userPassword: DemoPlaPassword123
LDIF
----
=== Delegate Administration of the People Branch
As `cn=Directory Manager`, create `ou=People,dc=example,dc=com` and add two access control instructions (ACIs) to it. The first ACI allows `pla-user` to add and delete `inetOrgPerson` entries below `ou=People`. The second allows updates to the listed attributes on those entries. The `password-reset` privilege and write access to `userPassword` together allow the delegate to reset passwords in this branch.
[source,bash]
----
docker compose exec -T opendj /opt/opendj/bin/ldapmodify \
  --hostname localhost --port 1389 --bindDN 'cn=Directory Manager' \
  --bindPassword "$OPENDJ_ROOT_PASSWORD" <<'LDIF'
dn: ou=People,dc=example,dc=com
changetype: add
objectClass: organizationalUnit
ou: People
dn: ou=People,dc=example,dc=com
changetype: modify
add: aci
aci: (targetscope="subordinate")(targetfilter="(objectClass=inetOrgPerson)")
 (version 3.0; acl "PLA manages People entries";
 allow (add,delete) userdn="ldap:///uid=pla-user,dc=example,dc=com";)
aci: (targetscope="subordinate")(targetfilter="(objectClass=inetOrgPerson)")
 (targetattr="cn || sn || givenName || mail || telephoneNumber || description || userPassword")
 (version 3.0; acl "PLA updates People profiles and passwords";
 allow (write) userdn="ldap:///uid=pla-user,dc=example,dc=com";)
-
dn: uid=pla-user,dc=example,dc=com
changetype: modify
add: ds-privilege-name
ds-privilege-name: password-reset
-
dn: uid=demo-user,ou=People,dc=example,dc=com
changetype: add
objectClass: inetOrgPerson
uid: demo-user
cn: Demo User
sn: User
mail: demo-user@example.com
description: Demo account
LDIF
----
If `ou=People` already exists, omit the first LDIF record. For more on how OpenDJ evaluates these rules, see xref:../admin-guide/chap-privileges-acis.adoc#aci-required[ACI Required For LDAP Operations] and xref:./delegate-password-reset.adoc[Delegate Password Reset Permissions].
=== Sign In and Verify Access
. Open link:http://127.0.0.1:8080/[phpLDAPadmin] in a browser.
. Enter `uid=pla-user,dc=example,dc=com` in the *User ID* field and `DemoPlaPassword123` in the *Password* field. Click *Login*.
+
image::images/phpldapadmin-login.png[phpLDAPadmin login form with the delegate's DN]
. Open the sidebar if it is collapsed. Expand `dc=example,dc=com` and `ou=People` in the tree, then select `uid=demo-user`.
+
image::images/phpldapadmin-directory.png[phpLDAPadmin directory tree with the demo user selected]
. To verify the delegated write permission, click *Edit Entry* and change *Description*. Click *Update*, then click *Update* again to confirm the change.
To stop the demo while keeping the directory data, run `docker compose down`.
=== Connect to an Existing OpenDJ Server
If OpenDJ already runs in Compose, add the `pla` service to that deployment and update `LDAP_HOST` and `depends_on` to use the OpenDJ service name. The health dependency requires an OpenDJ health check. For an OpenDJ server outside the Compose project, omit `depends_on` and use a hostname that resolves from the PLA container. If OpenDJ runs on a separate Docker network, attach PLA to that network as well.
Set `LDAP_PORT` to the LDAP listener port reachable from PLA and `LDAP_BASE_DN` to an existing base entry. Sign in with the full DN of an existing LDAP user and set `LDAP_LOGIN_OBJECTCLASS` to an object class on that entry. If the server requires a bind to read the schema or find the login entry, set `LDAP_USERNAME` and `LDAP_PASSWORD` for a lookup account with that access.
For an LDAPS listener, use `LDAP_CONNECTION: ldaps` and the listener port (1636 by default). Configure PLA to trust the certificate presented by OpenDJ. See xref:../admin-guide/chap-connection-handlers.adoc#setup-server-cert[Preparing for Secure Communications] and link:https://github.com/leenooks/phpLDAPadmin/wiki/Configuration-Variables[phpLDAPadmin configuration variables].
opendj-doc-generated-ref/src/main/asciidoc/images/phpldapadmin-directory.png
opendj-doc-generated-ref/src/main/asciidoc/images/phpldapadmin-login.png
opendj-doc-generated-ref/src/test/java/org/openidentityplatform/opendj/doc/AntoraPageTitlesIT.java
@@ -18,14 +18,21 @@
import static org.assertj.core.api.Assertions.assertThat;
import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.asciidoctor.Asciidoctor;
import org.asciidoctor.Options;
import org.asciidoctor.SafeMode;
import org.asciidoctor.ast.Document;
import org.asciidoctor.ast.Section;
import org.asciidoctor.extension.IncludeProcessor;
import org.asciidoctor.extension.PreprocessorReader;
import org.forgerock.testng.ForgeRockTestCase;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
@@ -37,12 +44,16 @@
public class AntoraPageTitlesIT extends ForgeRockTestCase {
    private Asciidoctor asciidoctor;
    private File buildDirectory;
    private Path modulesDirectory;
    @BeforeClass
    public void start() {
        buildDirectory = new File(System.getProperty("docBuildDirectory",
                new File(System.getProperty("basedir", "."), "target/asciidoc").getPath()));
        modulesDirectory = buildDirectory.toPath().resolve("antora/modules");
        asciidoctor = Asciidoctor.Factory.create();
        asciidoctor.javaExtensionRegistry().includeProcessor(
                new RootPartialIncludeProcessor(modulesDirectory.resolve("ROOT/partials")));
    }
    @AfterClass(alwaysRun = true)
@@ -75,23 +86,36 @@
                             "alias-dereferencing-example", "alias-dereferencing-troubleshooting" } },
            { "admin-guide", "chap-ldap-transactions", "LDAP Transactions (RFC 5805)",
              new String[] { "chap-ldap-transactions", "ldap-transactions-discover", "ldap-transactions-use",
                             "ldap-transactions-troubleshoot" } }
                             "ldap-transactions-troubleshoot" } },
            { "how-to", "phpldapadmin", "Connect phpLDAPadmin to OpenDJ in Docker",
              new String[] { "how-to-phpldapadmin", "_start_opendj_and_phpldapadmin", "_create_a_pla_login",
                             "_delegate_administration_of_the_people_branch", "_sign_in_and_verify_access",
                             "_connect_to_an_existing_opendj_server" } }
        };
    }
    @Test
    public void allGeneratedPagesHaveDocumentTitles() throws IOException {
        final List<Path> pages;
        try (Stream<Path> paths = Files.walk(modulesDirectory)) {
            pages = paths.filter(Files::isRegularFile)
                    .map(modulesDirectory::relativize)
                    .filter(path -> path.getNameCount() >= 3 && "pages".equals(path.getName(1).toString()))
                    .filter(path -> path.getFileName().toString().endsWith(".adoc"))
                    .sorted()
                    .collect(Collectors.toList());
        }
        assertThat(pages).as("Antora pages in %s", modulesDirectory).isNotEmpty().allSatisfy(page -> {
            final File input = modulesDirectory.resolve(page).toFile();
            assertThat(readDocumentTitle(input)).as("document title of %s", page).isNotBlank();
        });
    }
    @Test(dataProvider = "pages")
    public void generatedPageHasDocumentTitle(String guide, String page, String title, String[] fragments) {
        final File input = new File(buildDirectory, "antora/modules/" + guide + "/pages/" + page + ".adoc");
        final File input = modulesDirectory.resolve(guide + "/pages/" + page + ".adoc").toFile();
        assertThat(input).isFile();
        // Antora extracts metadata from the header. A full parse can fall back to a section
        // title and conceal a missing document header, although Antora publishes "Untitled".
        final Document document = asciidoctor.loadFile(input,
                Options.builder().safe(SafeMode.SAFE).attributes(Map.of("env-site", ""))
                        .parseHeaderOnly(true).build());
        assertThat(document.getDoctitle()).as("document title of %s", input).isEqualTo(title);
        // Without a header, Asciidoctor can still return the title attribute, which Antora ignores.
        assertThat(document.hasAttribute("title"))
                .as("%s must have a document header rather than a :title: attribute", input).isFalse();
        assertThat(readDocumentTitle(input)).as("document title of %s", input).isEqualTo(title);
        final String html = asciidoctor.convertFile(input,
                Options.builder().safe(SafeMode.SAFE).attributes(Map.of("env-site", ""))
                        .standalone(false).toFile(false).build());
@@ -101,6 +125,69 @@
        }
    }
    @DataProvider
    public Object[][] documentTitles() {
        return new Object[][] {
            { "= Heading\n:title: Browser Title\n", "Browser Title" },
            { ":title: Browser Title\n", null },
            { "== Section\n", null }
        };
    }
    @Test(dataProvider = "documentTitles")
    public void readsTitleOnlyWhenDocumentHasHeader(String source, String expectedTitle) throws IOException {
        final Path page = Files.createTempFile("antora-page-title-", ".adoc");
        try {
            Files.writeString(page, source);
            assertThat(readDocumentTitle(page.toFile())).isEqualTo(expectedTitle);
        } finally {
            Files.delete(page);
        }
    }
    private String readDocumentTitle(File input) {
        // Antora extracts metadata from the header. A full parse can fall back to a section
        // title and conceal a missing document header, although Antora publishes "Untitled".
        final Document document = asciidoctor.loadFile(input,
                Options.builder().safe(SafeMode.SAFE).attributes(Map.of("env-site", ""))
                        .parseHeaderOnly(true).build());
        // Antora publishes the resolved title only when the document has a header section.
        final boolean hasHeader = document.findBy(Map.of()).stream()
                .filter(Section.class::isInstance)
                .map(Section.class::cast)
                .anyMatch(section -> "header".equals(section.getSectionName()));
        return hasHeader ? document.getDoctitle() : null;
    }
    /** Resolves Antora's ROOT partials, which can supply a page header such as the dsconfig reference title. */
    private static final class RootPartialIncludeProcessor extends IncludeProcessor {
        private static final String PREFIX = "ROOT:partial$";
        private final Path partialsDirectory;
        private RootPartialIncludeProcessor(Path partialsDirectory) {
            this.partialsDirectory = partialsDirectory.toAbsolutePath().normalize();
        }
        @Override
        public boolean handles(String target) {
            return target.startsWith(PREFIX);
        }
        @Override
        public void process(Document document, PreprocessorReader reader, String target, Map<String, Object> attributes) {
            final Path partial = partialsDirectory.resolve(target.substring(PREFIX.length())).normalize();
            if (!partial.startsWith(partialsDirectory)) {
                throw new IllegalArgumentException("Invalid Antora ROOT partial: " + target);
            }
            final String path = partial.toString();
            try {
                reader.pushInclude(Files.readString(partial), path, path, 1, attributes);
            } catch (IOException e) {
                throw new UncheckedIOException("Cannot read Antora partial " + partial, e);
            }
        }
    }
    @Test
    public void releaseHistoryKeepsPublishedText() {
        final String html = renderReleaseHistory();